-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[11.x] Fix SQLite schema dumps containing internal
sqlite_*
objects (…
…#52135) * Add failing test * Remove all `CREATE TABLE sqlite_*` statements from schema dump * Wip
- Loading branch information
1 parent
2cefbbd
commit 094d4eb
Showing
2 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Database; | ||
|
||
use Illuminate\Support\Facades\DB; | ||
use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles; | ||
|
||
class SchemaStateTest extends DatabaseTestCase | ||
{ | ||
use InteractsWithPublishedFiles; | ||
|
||
protected $files = [ | ||
'database/schema', | ||
]; | ||
|
||
public function testSchemaDumpOnSqlite() | ||
{ | ||
if ($this->driver !== 'sqlite') { | ||
$this->markTestSkipped('Test requires a SQLite connection.'); | ||
} | ||
|
||
$connection = DB::connection('sqlite'); | ||
$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 UNIQUE INDEX users_email_unique on users (email);'); | ||
$connection->statement('INSERT INTO users (email, name) VALUES ("[email protected]", "Taylor Otwell");'); | ||
$connection->statement('PRAGMA optimize;'); | ||
|
||
$this->app['files']->ensureDirectoryExists(database_path('schema')); | ||
|
||
$connection->getSchemaState()->dump($connection, database_path('schema/sqlite-schema.sql')); | ||
|
||
$this->assertFileDoesNotContains([ | ||
'sqlite_sequence', | ||
'sqlite_stat1', | ||
'sqlite_stat4', | ||
], 'database/schema/sqlite-schema.sql'); | ||
} | ||
} |