diff --git a/src/Schema/CockroachSchemaState.php b/src/Schema/CockroachSchemaState.php index 6c7af3b..4263368 100644 --- a/src/Schema/CockroachSchemaState.php +++ b/src/Schema/CockroachSchemaState.php @@ -50,7 +50,7 @@ public function dump(Connection $connection, $path): void public function load($path): void { $fileContents = $this->files->get($path); - if (Str::squish($fileContents) === '') { + if ($fileContents === '') { throw new \RuntimeException(sprintf('file %s is empty', $path)); } diff --git a/tests/Integration/Database/DumpAndLoadSchemaTest.php b/tests/Integration/Database/DumpAndLoadSchemaTest.php index b7a6590..8bca962 100644 --- a/tests/Integration/Database/DumpAndLoadSchemaTest.php +++ b/tests/Integration/Database/DumpAndLoadSchemaTest.php @@ -13,6 +13,8 @@ protected function setUp(): void public function test_exporting_an_sql_dump() { + File::ensureDirectoryExists(database_path('schema-test')); + if ($this->app['config']->get('database.default') !== 'testing') { $this->artisan('db:wipe', ['--drop-views' => true]); } @@ -25,22 +27,25 @@ public function test_exporting_an_sql_dump() $this->artisan('migrate', $options); $this->beforeApplicationDestroyed(function () use ($options) { - File::delete(database_path('schema/crdb-schema.sql')); + File::delete(database_path('schema-test/crdb-schema.sql')); $this->artisan('migrate:rollback', $options); }); $this->artisan('schema:dump', [ '--database' => 'crdb', + '--path' => database_path('schema-test/crdb-schema.sql'), ]) ->assertSuccessful(); + + $this->assertFileExists(database_path('schema-test/crdb-schema.sql')); } public function test_importing_an_sql_dump() { // Make sure the schema direct exists first - File::ensureDirectoryExists(database_path('schema')); - File::copy(__DIR__ . '/stubs/schema-dump.sql', database_path('schema/crdb-schema.sql')); + File::ensureDirectoryExists(database_path('schema-test')); + File::copy(__DIR__ . '/stubs/schema-dump.sql', database_path('schema-test/crdb-schema.sql')); if ($this->app['config']->get('database.default') !== 'testing') { $this->artisan('db:wipe', ['--drop-views' => true]); @@ -57,7 +62,10 @@ public function test_importing_an_sql_dump() $this->artisan('migrate:rollback', $options); }); - $this->artisan('migrate', $options); + $this->artisan('migrate', [ + ...$options, + ...['--schema-path' => database_path('schema-test/crdb-schema.sql')] + ]); $this->assertDatabaseCount('migrations', 2);