aboutsummaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2018-12-05 11:39:51 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-01-23 13:28:23 +0100
commit842af5c3571c5318ae4e1c81dc52457fbf6d3f21 (patch)
treed934e15836d49e4c095aacedda947c1dc792d850 /app
parentdfd0a7bc5feb4fd7b77d7e2f3a25c5c3febc1eba (diff)
downloadwallabag-842af5c3571c5318ae4e1c81dc52457fbf6d3f21.tar.gz
wallabag-842af5c3571c5318ae4e1c81dc52457fbf6d3f21.tar.zst
wallabag-842af5c3571c5318ae4e1c81dc52457fbf6d3f21.zip
Add SQLite & PG migration
Also remove the forced `server_version` from dbal config to avoid an hard overriding across all database.
Diffstat (limited to 'app')
-rw-r--r--app/DoctrineMigrations/Version20181202073750.php46
1 files changed, 41 insertions, 5 deletions
diff --git a/app/DoctrineMigrations/Version20181202073750.php b/app/DoctrineMigrations/Version20181202073750.php
index b6ad8bd7..5978291e 100644
--- a/app/DoctrineMigrations/Version20181202073750.php
+++ b/app/DoctrineMigrations/Version20181202073750.php
@@ -6,21 +6,39 @@ use Doctrine\DBAL\Schema\Schema;
6use Wallabag\CoreBundle\Doctrine\WallabagMigration; 6use Wallabag\CoreBundle\Doctrine\WallabagMigration;
7 7
8/** 8/**
9 * Add 2fa OTP (named google authenticator). 9 * Add 2fa OTP stuff.
10 */ 10 */
11final class Version20181202073750 extends WallabagMigration 11final class Version20181202073750 extends WallabagMigration
12{ 12{
13 public function up(Schema $schema): void 13 public function up(Schema $schema): void
14 { 14 {
15 $tableName = $this->getTable('annotation');
16
17 switch ($this->connection->getDatabasePlatform()->getName()) { 15 switch ($this->connection->getDatabasePlatform()->getName()) {
18 case 'sqlite': 16 case 'sqlite':
17 $this->addSql('DROP INDEX UNIQ_1D63E7E5C05FB297');
18 $this->addSql('DROP INDEX UNIQ_1D63E7E5A0D96FBF');
19 $this->addSql('DROP INDEX UNIQ_1D63E7E592FC23A8');
20 $this->addSql('CREATE TEMPORARY TABLE __temp__' . $this->getTable('user', true) . ' AS SELECT id, username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, roles, name, created_at, updated_at, authCode, twoFactorAuthentication FROM ' . $this->getTable('user', true) . '');
21 $this->addSql('DROP TABLE ' . $this->getTable('user', true) . '');
22 $this->addSql('CREATE TABLE ' . $this->getTable('user', true) . ' (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, username VARCHAR(180) NOT NULL COLLATE BINARY, username_canonical VARCHAR(180) NOT NULL COLLATE BINARY, email VARCHAR(180) NOT NULL COLLATE BINARY, email_canonical VARCHAR(180) NOT NULL COLLATE BINARY, enabled BOOLEAN NOT NULL, password VARCHAR(255) NOT NULL COLLATE BINARY, last_login DATETIME DEFAULT NULL, password_requested_at DATETIME DEFAULT NULL, name CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, authCode INTEGER DEFAULT NULL, emailTwoFactor BOOLEAN NOT NULL, salt VARCHAR(255) DEFAULT NULL, confirmation_token VARCHAR(180) DEFAULT NULL, roles CLOB NOT NULL --(DC2Type:array)
23 , googleAuthenticatorSecret VARCHAR(255) DEFAULT NULL, backupCodes CLOB DEFAULT NULL --(DC2Type:json_array)
24 )');
25 $this->addSql('INSERT INTO ' . $this->getTable('user', true) . ' (id, username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, roles, name, created_at, updated_at, authCode, emailTwoFactor) SELECT id, username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, roles, name, created_at, updated_at, authCode, twoFactorAuthentication FROM __temp__' . $this->getTable('user', true) . '');
26 $this->addSql('DROP TABLE __temp__' . $this->getTable('user', true) . '');
27 $this->addSql('CREATE UNIQUE INDEX UNIQ_1D63E7E5C05FB297 ON ' . $this->getTable('user', true) . ' (confirmation_token)');
28 $this->addSql('CREATE UNIQUE INDEX UNIQ_1D63E7E5A0D96FBF ON ' . $this->getTable('user', true) . ' (email_canonical)');
29 $this->addSql('CREATE UNIQUE INDEX UNIQ_1D63E7E592FC23A8 ON ' . $this->getTable('user', true) . ' (username_canonical)');
19 break; 30 break;
20 case 'mysql': 31 case 'mysql':
21 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' ADD googleAuthenticatorSecret VARCHAR(191) DEFAULT NULL, CHANGE twoFactorAuthentication emailTwoFactor BOOLEAN NOT NULL, DROP trusted, ADD backupCodes LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json_array)\''); 32 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' ADD googleAuthenticatorSecret VARCHAR(191) DEFAULT NULL');
33 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE twoFactorAuthentication emailTwoFactor BOOLEAN NOT NULL');
34 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' DROP trusted');
35 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' ADD backupCodes LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json_array)\'');
22 break; 36 break;
23 case 'postgresql': 37 case 'postgresql':
38 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' ADD googleAuthenticatorSecret VARCHAR(191) DEFAULT NULL');
39 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' RENAME COLUMN twofactorauthentication TO emailTwoFactor');
40 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' DROP trusted');
41 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' ADD backupCodes TEXT DEFAULT NULL');
24 break; 42 break;
25 } 43 }
26 } 44 }
@@ -29,11 +47,29 @@ final class Version20181202073750 extends WallabagMigration
29 { 47 {
30 switch ($this->connection->getDatabasePlatform()->getName()) { 48 switch ($this->connection->getDatabasePlatform()->getName()) {
31 case 'sqlite': 49 case 'sqlite':
50 $this->addSql('DROP INDEX UNIQ_1D63E7E592FC23A8');
51 $this->addSql('DROP INDEX UNIQ_1D63E7E5A0D96FBF');
52 $this->addSql('DROP INDEX UNIQ_1D63E7E5C05FB297');
53 $this->addSql('CREATE TEMPORARY TABLE __temp__' . $this->getTable('user', true) . ' AS SELECT id, username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, roles, name, created_at, updated_at, authCode, emailTwoFactor FROM "' . $this->getTable('user', true) . '"');
54 $this->addSql('DROP TABLE "' . $this->getTable('user', true) . '"');
55 $this->addSql('CREATE TABLE "' . $this->getTable('user', true) . '" (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, username VARCHAR(180) NOT NULL, username_canonical VARCHAR(180) NOT NULL, email VARCHAR(180) NOT NULL, email_canonical VARCHAR(180) NOT NULL, enabled BOOLEAN NOT NULL, password VARCHAR(255) NOT NULL, last_login DATETIME DEFAULT NULL, password_requested_at DATETIME DEFAULT NULL, name CLOB DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, authCode INTEGER DEFAULT NULL, twoFactorAuthentication BOOLEAN NOT NULL, salt VARCHAR(255) NOT NULL COLLATE BINARY, confirmation_token VARCHAR(255) DEFAULT NULL COLLATE BINARY, roles CLOB NOT NULL COLLATE BINARY, trusted CLOB DEFAULT NULL COLLATE BINARY)');
56 $this->addSql('INSERT INTO "' . $this->getTable('user', true) . '" (id, username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, roles, name, created_at, updated_at, authCode, twoFactorAuthentication) SELECT id, username, username_canonical, email, email_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, roles, name, created_at, updated_at, authCode, emailTwoFactor FROM __temp__' . $this->getTable('user', true) . '');
57 $this->addSql('DROP TABLE __temp__' . $this->getTable('user', true) . '');
58 $this->addSql('CREATE UNIQUE INDEX UNIQ_1D63E7E592FC23A8 ON "' . $this->getTable('user', true) . '" (username_canonical)');
59 $this->addSql('CREATE UNIQUE INDEX UNIQ_1D63E7E5A0D96FBF ON "' . $this->getTable('user', true) . '" (email_canonical)');
60 $this->addSql('CREATE UNIQUE INDEX UNIQ_1D63E7E5C05FB297 ON "' . $this->getTable('user', true) . '" (confirmation_token)');
32 break; 61 break;
33 case 'mysql': 62 case 'mysql':
34 $this->addSql('ALTER TABLE `' . $this->getTable('user') . '` DROP googleAuthenticatorSecret, CHANGE emailtwofactor twoFactorAuthentication BOOLEAN NOT NULL, ADD trusted TEXT DEFAULT NULL, DROP backupCodes'); 63 $this->addSql('ALTER TABLE `' . $this->getTable('user') . '` DROP googleAuthenticatorSecret');
64 $this->addSql('ALTER TABLE `' . $this->getTable('user') . '` CHANGE emailtwofactor twoFactorAuthentication BOOLEAN NOT NULL');
65 $this->addSql('ALTER TABLE `' . $this->getTable('user') . '` ADD trusted TEXT DEFAULT NULL');
66 $this->addSql('ALTER TABLE `' . $this->getTable('user') . '` DROP backupCodes');
35 break; 67 break;
36 case 'postgresql': 68 case 'postgresql':
69 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' DROP googleAuthenticatorSecret');
70 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' RENAME COLUMN emailTwoFactor TO twofactorauthentication');
71 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' ADD trusted TEXT DEFAULT NULL');
72 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' DROP backupCodes');
37 break; 73 break;
38 } 74 }
39 } 75 }