mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-22 17:11:07 +00:00
Make install command better support PostgreSQL
This commit is contained in:
parent
96cb024cf5
commit
49df7d8c52
2 changed files with 22 additions and 19 deletions
|
@ -198,13 +198,21 @@ class InstallCommand extends Command
|
|||
{
|
||||
$this->io->section('Step 2 of 4: Setting up database.');
|
||||
|
||||
$conn = $this->entityManager->getConnection();
|
||||
$databasePlatform = $conn->isConnected() ? $conn->getDatabasePlatform() : null;
|
||||
|
||||
// user want to reset everything? Don't care about what is already here
|
||||
if (true === $this->defaultInput->getOption('reset')) {
|
||||
$this->io->text('Dropping database, creating database and schema, clearing the cache');
|
||||
|
||||
$this->runCommand('doctrine:schema:drop', ['--force' => true, '--full-database' => true]);
|
||||
|
||||
if (!$databasePlatform instanceof PostgreSQLPlatform) {
|
||||
$this->runCommand('doctrine:database:drop', ['--force' => true]);
|
||||
$this->runCommand('doctrine:database:create');
|
||||
}
|
||||
|
||||
$this
|
||||
->runCommand('doctrine:database:drop', ['--force' => true])
|
||||
->runCommand('doctrine:database:create')
|
||||
->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true])
|
||||
->runCommand('cache:clear')
|
||||
;
|
||||
|
@ -231,11 +239,14 @@ class InstallCommand extends Command
|
|||
if ($this->io->confirm('It appears that your database already exists. Would you like to reset it?', false)) {
|
||||
$this->io->text('Dropping database, creating database and schema...');
|
||||
|
||||
$this
|
||||
->runCommand('doctrine:database:drop', ['--force' => true])
|
||||
->runCommand('doctrine:database:create')
|
||||
->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true])
|
||||
;
|
||||
$this->runCommand('doctrine:schema:drop', ['--force' => true, '--full-database' => true]);
|
||||
|
||||
if (!$databasePlatform instanceof PostgreSQLPlatform) {
|
||||
$this->runCommand('doctrine:database:drop', ['--force' => true]);
|
||||
$this->runCommand('doctrine:database:create');
|
||||
}
|
||||
|
||||
$this->runCommand('doctrine:migrations:migrate', ['--no-interaction' => true]);
|
||||
} elseif ($this->isSchemaPresent()) {
|
||||
if ($this->io->confirm('Seems like your database contains schema. Do you want to reset it?', false)) {
|
||||
$this->io->text('Dropping schema and creating schema...');
|
||||
|
|
|
@ -36,18 +36,6 @@ class InstallCommandTest extends WallabagTestCase
|
|||
|
||||
/** @var Connection $connection */
|
||||
$connection = $this->getTestClient()->getContainer()->get(ManagerRegistry::class)->getConnection();
|
||||
if ($connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
|
||||
/*
|
||||
* LOG: statement: CREATE DATABASE "wallabag"
|
||||
* ERROR: source database "template1" is being accessed by other users
|
||||
* DETAIL: There is 1 other session using the database.
|
||||
* STATEMENT: CREATE DATABASE "wallabag"
|
||||
* FATAL: database "wallabag" does not exist
|
||||
*
|
||||
* http://stackoverflow.com/a/14374832/569101
|
||||
*/
|
||||
$this->markTestSkipped('PostgreSQL spotted: can\'t find a good way to drop current database, skipping.');
|
||||
}
|
||||
|
||||
if ($connection->getDatabasePlatform() instanceof SqlitePlatform) {
|
||||
// Environnement variable useful only for sqlite to avoid the error "attempt to write a readonly database"
|
||||
|
@ -142,6 +130,10 @@ class InstallCommandTest extends WallabagTestCase
|
|||
|
||||
public function testRunInstallCommandWithDatabaseRemoved()
|
||||
{
|
||||
if ($this->getTestClient()->getContainer()->get(ManagerRegistry::class)->getConnection()->getDatabasePlatform() instanceof PostgreSQLPlatform) {
|
||||
$this->markTestSkipped('PostgreSQL spotted: can\'t find a good way to drop current database, skipping.');
|
||||
}
|
||||
|
||||
if ($this->getTestClient()->getContainer()->get(ManagerRegistry::class)->getConnection()->getDatabasePlatform() instanceof MySQLPlatform) {
|
||||
$this->markTestSkipped('Rollback are not properly handled for MySQL, skipping.');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue