Skip to content

Commit

Permalink
Merge pull request #4965 from morozov/issues/4963-sqlite-drop-create-…
Browse files Browse the repository at this point in the history
…database

Drop support for CREATE|DROP DATABASE in SQLite schema manager
  • Loading branch information
derrabus authored Nov 9, 2021
2 parents 6c044d5 + 587c332 commit 3fbd076
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 55 deletions.
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ awareness about deprecated code.

# Upgrade to 4.0

## BC BREAK: Removed `SqliteSchemaManager::createDatabase()` and `dropDatabase()` methods.

The `SqliteSchemaManager::createDatabase()` and `dropDatabase()` methods have been removed.

## BC BREAK: Removed `AbstractSchemaManager::dropAndCreate*()` and `::tryMethod()` methods.

The following `AbstractSchemaManager` methods have been removed:
Expand Down
43 changes: 0 additions & 43 deletions src/Schema/SqliteSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Doctrine\DBAL\Schema;

use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\SQLite;
use Doctrine\DBAL\Platforms\SqlitePlatform;
Expand All @@ -19,7 +18,6 @@
use function array_values;
use function assert;
use function count;
use function file_exists;
use function is_string;
use function preg_match;
use function preg_match_all;
Expand All @@ -31,7 +29,6 @@
use function strpos;
use function strtolower;
use function trim;
use function unlink;
use function usort;

use const CASE_LOWER;
Expand All @@ -43,46 +40,6 @@
*/
class SqliteSchemaManager extends AbstractSchemaManager
{
/**
* @deprecated Delete the database file using the filesystem.
*/
public function dropDatabase(string $database): void
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4963',
'SqliteSchemaManager::dropDatabase() is deprecated. Delete the database file using the filesystem.'
);

if (! file_exists($database)) {
return;
}

unlink($database);
}

/**
* @deprecated The engine will create the database file automatically.
*/
public function createDatabase(string $database): void
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/issues/4963',
'SqliteSchemaManager::createDatabase() is deprecated.'
. ' The engine will create the database file automatically.'
);

$params = $this->_conn->getParams();

$params['path'] = $database;
unset($params['memory']);

$conn = DriverManager::getConnection($params);
$conn->connect();
$conn->close();
}

public function renameTable(string $name, string $newName): void
{
$tableDiff = new TableDiff($name);
Expand Down
12 changes: 0 additions & 12 deletions tests/Functional/Schema/SqliteSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;

use function dirname;

class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
protected function supportsPlatform(AbstractPlatform $platform): bool
Expand All @@ -32,16 +30,6 @@ public function testListDatabases(): void
$this->schemaManager->listDatabases();
}

public function testCreateAndDropDatabase(): void
{
$path = dirname(__FILE__) . '/test_create_and_drop_sqlite_database.sqlite';

$this->schemaManager->createDatabase($path);
self::assertFileExists($path);
$this->schemaManager->dropDatabase($path);
self::assertFileDoesNotExist($path);
}

public function testRenameTable(): void
{
$this->createTestTable('oldname');
Expand Down

0 comments on commit 3fbd076

Please sign in to comment.