diff options
Diffstat (limited to 'app/DoctrineMigrations')
-rwxr-xr-x | app/DoctrineMigrations/Version20180405182455.php | 51 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20181128203230.php | 45 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20181202073750.php | 76 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20190117131816.php | 32 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20190129120000.php | 147 |
5 files changed, 351 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20180405182455.php b/app/DoctrineMigrations/Version20180405182455.php new file mode 100755 index 00000000..50fe97c7 --- /dev/null +++ b/app/DoctrineMigrations/Version20180405182455.php | |||
@@ -0,0 +1,51 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Schema\Schema; | ||
6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; | ||
7 | |||
8 | /** | ||
9 | * Add archived_at column and set its value to updated_at for is_archived entries. | ||
10 | */ | ||
11 | class Version20180405182455 extends WallabagMigration | ||
12 | { | ||
13 | /** | ||
14 | * @param Schema $schema | ||
15 | */ | ||
16 | public function up(Schema $schema) | ||
17 | { | ||
18 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
19 | |||
20 | $this->skipIf($entryTable->hasColumn('archived_at'), 'It seems that you already played this migration.'); | ||
21 | |||
22 | $entryTable->addColumn('archived_at', 'datetime', [ | ||
23 | 'notnull' => false, | ||
24 | ]); | ||
25 | } | ||
26 | |||
27 | public function postUp(Schema $schema) | ||
28 | { | ||
29 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
30 | $this->skipIf(!$entryTable->hasColumn('archived_at'), 'Unable to add archived_at colum'); | ||
31 | |||
32 | $this->connection->executeQuery( | ||
33 | 'UPDATE ' . $this->getTable('entry') . ' SET archived_at = updated_at WHERE is_archived = :is_archived', | ||
34 | [ | ||
35 | 'is_archived' => true, | ||
36 | ] | ||
37 | ); | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * @param Schema $schema | ||
42 | */ | ||
43 | public function down(Schema $schema) | ||
44 | { | ||
45 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
46 | |||
47 | $this->skipIf(!$entryTable->hasColumn('archived_at'), 'It seems that you already played this migration.'); | ||
48 | |||
49 | $entryTable->dropColumn('archived_at'); | ||
50 | } | ||
51 | } | ||
diff --git a/app/DoctrineMigrations/Version20181128203230.php b/app/DoctrineMigrations/Version20181128203230.php new file mode 100644 index 00000000..d1b09fc7 --- /dev/null +++ b/app/DoctrineMigrations/Version20181128203230.php | |||
@@ -0,0 +1,45 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Schema\Schema; | ||
6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; | ||
7 | |||
8 | /** | ||
9 | * Fix varchar field from vendor to work with utf8mb4. | ||
10 | */ | ||
11 | class Version20181128203230 extends WallabagMigration | ||
12 | { | ||
13 | /** | ||
14 | * @param Schema $schema | ||
15 | */ | ||
16 | public function up(Schema $schema) | ||
17 | { | ||
18 | $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration can only be applied on \'mysql\'.'); | ||
19 | |||
20 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `token` `token` varchar(191) NOT NULL'); | ||
21 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `scope` `scope` varchar(191)'); | ||
22 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `token` `token` varchar(191) NOT NULL'); | ||
23 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `scope` `scope` varchar(191)'); | ||
24 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `token` `token` varchar(191) NOT NULL'); | ||
25 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `scope` `scope` varchar(191)'); | ||
26 | $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `name` `name` varchar(191)'); | ||
27 | $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `section` `section` varchar(191)'); | ||
28 | $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `value` `value` varchar(191)'); | ||
29 | } | ||
30 | |||
31 | public function down(Schema $schema) | ||
32 | { | ||
33 | $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration can only be applied on \'mysql\'.'); | ||
34 | |||
35 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `token` `token` varchar(255) NOT NULL'); | ||
36 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_access_tokens') . ' CHANGE `scope` `scope` varchar(255)'); | ||
37 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `token` `token` varchar(255) NOT NULL'); | ||
38 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_auth_codes') . ' CHANGE `scope` `scope` varchar(255)'); | ||
39 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `token` `token` varchar(255) NOT NULL'); | ||
40 | $this->addSql('ALTER TABLE ' . $this->getTable('oauth2_refresh_tokens') . ' CHANGE `scope` `scope` varchar(255)'); | ||
41 | $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `name` `name` varchar(255)'); | ||
42 | $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `section` `section` varchar(255)'); | ||
43 | $this->addSql('ALTER TABLE ' . $this->getTable('craue_config_setting') . ' CHANGE `value` `value` varchar(255)'); | ||
44 | } | ||
45 | } | ||
diff --git a/app/DoctrineMigrations/Version20181202073750.php b/app/DoctrineMigrations/Version20181202073750.php new file mode 100644 index 00000000..5978291e --- /dev/null +++ b/app/DoctrineMigrations/Version20181202073750.php | |||
@@ -0,0 +1,76 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Schema\Schema; | ||
6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; | ||
7 | |||
8 | /** | ||
9 | * Add 2fa OTP stuff. | ||
10 | */ | ||
11 | final class Version20181202073750 extends WallabagMigration | ||
12 | { | ||
13 | public function up(Schema $schema): void | ||
14 | { | ||
15 | switch ($this->connection->getDatabasePlatform()->getName()) { | ||
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)'); | ||
30 | break; | ||
31 | case 'mysql': | ||
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)\''); | ||
36 | break; | ||
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'); | ||
42 | break; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public function down(Schema $schema): void | ||
47 | { | ||
48 | switch ($this->connection->getDatabasePlatform()->getName()) { | ||
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)'); | ||
61 | break; | ||
62 | case 'mysql': | ||
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'); | ||
67 | break; | ||
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'); | ||
73 | break; | ||
74 | } | ||
75 | } | ||
76 | } | ||
diff --git a/app/DoctrineMigrations/Version20190117131816.php b/app/DoctrineMigrations/Version20190117131816.php new file mode 100644 index 00000000..6548b9fa --- /dev/null +++ b/app/DoctrineMigrations/Version20190117131816.php | |||
@@ -0,0 +1,32 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Schema\Schema; | ||
6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; | ||
7 | |||
8 | /** | ||
9 | * Add updated_at fields to site_credential table. | ||
10 | */ | ||
11 | final class Version20190117131816 extends WallabagMigration | ||
12 | { | ||
13 | public function up(Schema $schema): void | ||
14 | { | ||
15 | $siteCredentialTable = $schema->getTable($this->getTable('site_credential')); | ||
16 | |||
17 | $this->skipIf($siteCredentialTable->hasColumn('updated_at'), 'It seems that you already played this migration.'); | ||
18 | |||
19 | $siteCredentialTable->addColumn('updated_at', 'datetime', [ | ||
20 | 'notnull' => false, | ||
21 | ]); | ||
22 | } | ||
23 | |||
24 | public function down(Schema $schema): void | ||
25 | { | ||
26 | $siteCredentialTable = $schema->getTable($this->getTable('site_credential')); | ||
27 | |||
28 | $this->skipIf(!$siteCredentialTable->hasColumn('updated_at'), 'It seems that you already played this migration.'); | ||
29 | |||
30 | $siteCredentialTable->dropColumn('updated_at'); | ||
31 | } | ||
32 | } | ||
diff --git a/app/DoctrineMigrations/Version20190129120000.php b/app/DoctrineMigrations/Version20190129120000.php new file mode 100644 index 00000000..3632e762 --- /dev/null +++ b/app/DoctrineMigrations/Version20190129120000.php | |||
@@ -0,0 +1,147 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Schema\Schema; | ||
6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; | ||
7 | |||
8 | /** | ||
9 | * Add missing entries in craue_config_setting. | ||
10 | */ | ||
11 | final class Version20190129120000 extends WallabagMigration | ||
12 | { | ||
13 | private $settings = [ | ||
14 | [ | ||
15 | 'name' => 'carrot', | ||
16 | 'value' => '1', | ||
17 | 'section' => 'entry', | ||
18 | ], | ||
19 | [ | ||
20 | 'name' => 'share_diaspora', | ||
21 | 'value' => '1', | ||
22 | 'section' => 'entry', | ||
23 | ], | ||
24 | [ | ||
25 | 'name' => 'diaspora_url', | ||
26 | 'value' => 'http://diasporapod.com', | ||
27 | 'section' => 'entry', | ||
28 | ], | ||
29 | [ | ||
30 | 'name' => 'share_shaarli', | ||
31 | 'value' => '1', | ||
32 | 'section' => 'entry', | ||
33 | ], | ||
34 | [ | ||
35 | 'name' => 'shaarli_url', | ||
36 | 'value' => 'http://myshaarli.com', | ||
37 | 'section' => 'entry', | ||
38 | ], | ||
39 | [ | ||
40 | 'name' => 'share_mail', | ||
41 | 'value' => '1', | ||
42 | 'section' => 'entry', | ||
43 | ], | ||
44 | [ | ||
45 | 'name' => 'share_twitter', | ||
46 | 'value' => '1', | ||
47 | 'section' => 'entry', | ||
48 | ], | ||
49 | [ | ||
50 | 'name' => 'show_printlink', | ||
51 | 'value' => '1', | ||
52 | 'section' => 'entry', | ||
53 | ], | ||
54 | [ | ||
55 | 'name' => 'export_epub', | ||
56 | 'value' => '1', | ||
57 | 'section' => 'export', | ||
58 | ], | ||
59 | [ | ||
60 | 'name' => 'export_mobi', | ||
61 | 'value' => '1', | ||
62 | 'section' => 'export', | ||
63 | ], | ||
64 | [ | ||
65 | 'name' => 'export_pdf', | ||
66 | 'value' => '1', | ||
67 | 'section' => 'export', | ||
68 | ], | ||
69 | [ | ||
70 | 'name' => 'export_csv', | ||
71 | 'value' => '1', | ||
72 | 'section' => 'export', | ||
73 | ], | ||
74 | [ | ||
75 | 'name' => 'export_json', | ||
76 | 'value' => '1', | ||
77 | 'section' => 'export', | ||
78 | ], | ||
79 | [ | ||
80 | 'name' => 'export_txt', | ||
81 | 'value' => '1', | ||
82 | 'section' => 'export', | ||
83 | ], | ||
84 | [ | ||
85 | 'name' => 'export_xml', | ||
86 | 'value' => '1', | ||
87 | 'section' => 'export', | ||
88 | ], | ||
89 | [ | ||
90 | 'name' => 'piwik_enabled', | ||
91 | 'value' => '0', | ||
92 | 'section' => 'analytics', | ||
93 | ], | ||
94 | [ | ||
95 | 'name' => 'piwik_host', | ||
96 | 'value' => 'v2.wallabag.org', | ||
97 | 'section' => 'analytics', | ||
98 | ], | ||
99 | [ | ||
100 | 'name' => 'piwik_site_id', | ||
101 | 'value' => '1', | ||
102 | 'section' => 'analytics', | ||
103 | ], | ||
104 | [ | ||
105 | 'name' => 'demo_mode_enabled', | ||
106 | 'value' => '0', | ||
107 | 'section' => 'misc', | ||
108 | ], | ||
109 | [ | ||
110 | 'name' => 'demo_mode_username', | ||
111 | 'value' => 'wallabag', | ||
112 | 'section' => 'misc', | ||
113 | ], | ||
114 | [ | ||
115 | 'name' => 'wallabag_support_url', | ||
116 | 'value' => 'https://www.wallabag.org/pages/support.html', | ||
117 | 'section' => 'misc', | ||
118 | ], | ||
119 | ]; | ||
120 | |||
121 | /** | ||
122 | * @param Schema $schema | ||
123 | */ | ||
124 | public function up(Schema $schema) | ||
125 | { | ||
126 | foreach ($this->settings as $setting) { | ||
127 | $settingEnabled = $this->container | ||
128 | ->get('doctrine.orm.default_entity_manager') | ||
129 | ->getConnection() | ||
130 | ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = '" . $setting['name'] . "'"); | ||
131 | |||
132 | if (false !== $settingEnabled) { | ||
133 | continue; | ||
134 | } | ||
135 | |||
136 | $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('" . $setting['name'] . "', '" . $setting['value'] . "', '" . $setting['section'] . "');"); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * @param Schema $schema | ||
142 | */ | ||
143 | public function down(Schema $schema) | ||
144 | { | ||
145 | $this->skipIf(true, 'These settings are required and should not be removed.'); | ||
146 | } | ||
147 | } | ||