diff --git a/src/Illuminate/Database/Schema/SqliteSchemaState.php b/src/Illuminate/Database/Schema/SqliteSchemaState.php index d7195f495b47..ad48a3dae4b5 100644 --- a/src/Illuminate/Database/Schema/SqliteSchemaState.php +++ b/src/Illuminate/Database/Schema/SqliteSchemaState.php @@ -21,7 +21,7 @@ public function dump(Connection $connection, $path) // ])); - $migrations = preg_replace('/CREATE TABLE sqlite_.+\);[\r\n]+/is', '', $process->getOutput()); + $migrations = preg_replace('/CREATE TABLE sqlite_.+?\);[\r\n]+/is', '', $process->getOutput()); $this->files->put($path, $migrations.PHP_EOL); diff --git a/tests/Integration/Database/Sqlite/SchemaStateTest.php b/tests/Integration/Database/Sqlite/SchemaStateTest.php index 5bb30f1b34a4..fe69737aa33f 100644 --- a/tests/Integration/Database/Sqlite/SchemaStateTest.php +++ b/tests/Integration/Database/Sqlite/SchemaStateTest.php @@ -50,7 +50,8 @@ public function testSchemaDumpOnSqlite() $connection = DB::connection(); $connection->getSchemaBuilder()->createDatabase($connection->getConfig('database')); - $connection->statement('CREATE TABLE users(id integer primary key autoincrement not null, email varchar not null, name varchar not null);'); + $connection->statement('CREATE TABLE IF NOT EXISTS migrations (id integer primary key autoincrement not null, migration varchar not null, batch integer not null);'); + $connection->statement('CREATE TABLE users (id integer primary key autoincrement not null, email varchar not null, name varchar not null);'); $connection->statement('INSERT INTO users (email, name) VALUES ("taylor@laravel.com", "Taylor Otwell");'); $this->assertTrue($connection->table('sqlite_sequence')->exists()); @@ -60,6 +61,7 @@ public function testSchemaDumpOnSqlite() $connection->getSchemaState()->dump($connection, database_path('schema/sqlite-schema.sql')); $this->assertFileContains([ + 'CREATE TABLE migrations', 'CREATE TABLE users', ], 'database/schema/sqlite-schema.sql'); $this->assertFileNotContains([