Last active
August 3, 2018 00:00
-
-
Save bdelespierre/dc586a757907884087150c2dd96db799 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include __DIR__ . '/../vendor/autoload.php'; | |
/* | |
|-------------------------------------------------------------------------- | |
| Create The Application | |
|-------------------------------------------------------------------------- | |
| | |
| The first thing we will do is create a new Laravel application instance | |
| which serves as the "glue" for all the components of Laravel, and is | |
| the IoC container for the system binding all of the various parts. | |
| | |
*/ | |
$app = include __DIR__ . '/app.php'; | |
$app->make(App\Console\Kernel::class)->bootstrap(); | |
/* | |
|-------------------------------------------------------------------------- | |
| Prepare the exemplar.sqlite database | |
|-------------------------------------------------------------------------- | |
| | |
| We want to create an exemplar database that will be used by | |
| Tests\DatabaseMigration so it can avoid running migrate:fresh | |
| command on every test which is very time consuming. Instead, | |
| the exemplar.sqlite file is simply copied over database.sqlite. | |
| | |
*/ | |
if (config('database.connections')[config('database.default')]['driver'] == 'sqlite') { | |
echo "Making exemplar database..."; | |
$database = config('database.connections')[config('database.default')]['database']; | |
$exemplar = dirname($database) . '/database_exemplar.sqlite'; | |
// delete existing database file | |
if (file_exists($database)) { | |
unlink($database); | |
} | |
// creates an empty database and run the migrations | |
touch($database); | |
// reconnect the database (just in case it previously existed) | |
DB::reconnect(); | |
// migrate & seed the proper tables | |
Artisan::call('migrate'); | |
// copy it to exemplar | |
copy($database, $exemplar); | |
echo " done!\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment