-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In SQLite, creating an index in another schema is done by prepending the index name with the schema, while the table name must be unprefixed.
- Loading branch information
Showing
4 changed files
with
87 additions
and
1 deletion.
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
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,37 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Tests\Functional\Platform; | ||
|
||
use Doctrine\DBAL\DriverManager; | ||
use Doctrine\DBAL\Platforms\SqlitePlatform; | ||
use Doctrine\DBAL\Schema\Table; | ||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
use Doctrine\DBAL\Types\Types; | ||
|
||
class OtherSchemaTest extends FunctionalTestCase | ||
{ | ||
public function testATableCanBeCreatedInAnotherSchema(): void | ||
{ | ||
$databasePlatform = $this->connection->getDatabasePlatform(); | ||
if (! ($databasePlatform instanceof SqlitePlatform)) { | ||
self::markTestSkipped('This test requires SQLite'); | ||
} | ||
|
||
$this->connection->executeStatement("ATTACH DATABASE '/tmp/test_other_schema.sqlite' AS other"); | ||
$databasePlatform->disableSchemaEmulation(); | ||
|
||
$table = new Table('other.test_other_schema'); | ||
$table->addColumn('id', Types::INTEGER); | ||
$table->addIndex(['id']); | ||
|
||
$this->dropAndCreateTable($table); | ||
$this->connection->insert('other.test_other_schema', ['id' => 1]); | ||
|
||
self::assertEquals(1, $this->connection->fetchOne('SELECT COUNT(*) FROM other.test_other_schema')); | ||
$connection = DriverManager::getConnection( | ||
['url' => 'sqlite:////tmp/test_other_schema.sqlite'], | ||
); | ||
$onlineTable = $connection->createSchemaManager()->introspectTable('test_other_schema'); | ||
self::assertCount(1, $onlineTable->getIndexes()); | ||
} | ||
} |
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