diff options
Diffstat (limited to 'app/DoctrineMigrations')
18 files changed, 976 insertions, 34 deletions
diff --git a/app/DoctrineMigrations/Version20160410190541.php b/app/DoctrineMigrations/Version20160410190541.php index f034b0e4..ebf4135f 100644 --- a/app/DoctrineMigrations/Version20160410190541.php +++ b/app/DoctrineMigrations/Version20160410190541.php | |||
@@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; | |||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | 7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | 8 | use Symfony\Component\DependencyInjection\ContainerInterface; |
9 | 9 | ||
10 | /** | ||
11 | * Added foreign keys for account resetting | ||
12 | */ | ||
10 | class Version20160410190541 extends AbstractMigration implements ContainerAwareInterface | 13 | class Version20160410190541 extends AbstractMigration implements ContainerAwareInterface |
11 | { | 14 | { |
12 | /** | 15 | /** |
@@ -21,7 +24,7 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI | |||
21 | 24 | ||
22 | private function getTable($tableName) | 25 | private function getTable($tableName) |
23 | { | 26 | { |
24 | return $this->container->getParameter('database_table_prefix') . $tableName; | 27 | return $this->container->getParameter('database_table_prefix').$tableName; |
25 | } | 28 | } |
26 | 29 | ||
27 | /** | 30 | /** |
@@ -29,13 +32,15 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI | |||
29 | */ | 32 | */ |
30 | public function up(Schema $schema) | 33 | public function up(Schema $schema) |
31 | { | 34 | { |
32 | if ($this->connection->getDatabasePlatform()->getName() == 'postgresql') { | 35 | $entryTable = $schema->getTable($this->getTable('entry')); |
33 | $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" ADD uuid UUID DEFAULT NULL'); | ||
34 | } else { | ||
35 | $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" ADD uuid LONGTEXT DEFAULT NULL'); | ||
36 | } | ||
37 | 36 | ||
38 | $this->addSql("INSERT INTO \"".$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('share_public', '1', 'entry')"); | 37 | $this->skipIf($entryTable->hasColumn('uid'), 'It seems that you already played this migration.'); |
38 | |||
39 | $entryTable->addColumn('uid', 'string', [ | ||
40 | 'notnull' => false, | ||
41 | 'length' => 23, | ||
42 | ]); | ||
43 | $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_public', '1', 'entry')"); | ||
39 | } | 44 | } |
40 | 45 | ||
41 | /** | 46 | /** |
@@ -43,9 +48,9 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI | |||
43 | */ | 48 | */ |
44 | public function down(Schema $schema) | 49 | public function down(Schema $schema) |
45 | { | 50 | { |
46 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.'); | 51 | $entryTable = $schema->getTable($this->getTable('entry')); |
52 | $entryTable->dropColumn('uid'); | ||
47 | 53 | ||
48 | $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" DROP uuid'); | 54 | $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'"); |
49 | $this->addSql("DELETE FROM \"".$this->getTable('craue_config_setting')."\" WHERE name = 'share_public'"); | ||
50 | } | 55 | } |
51 | } | 56 | } |
diff --git a/app/DoctrineMigrations/Version20160812120952.php b/app/DoctrineMigrations/Version20160812120952.php index 3aafea64..bd6e8d63 100644 --- a/app/DoctrineMigrations/Version20160812120952.php +++ b/app/DoctrineMigrations/Version20160812120952.php | |||
@@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; | |||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | 7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | 8 | use Symfony\Component\DependencyInjection\ContainerInterface; |
9 | 9 | ||
10 | /** | ||
11 | * Added name field on wallabag_oauth2_clients | ||
12 | */ | ||
10 | class Version20160812120952 extends AbstractMigration implements ContainerAwareInterface | 13 | class Version20160812120952 extends AbstractMigration implements ContainerAwareInterface |
11 | { | 14 | { |
12 | /** | 15 | /** |
@@ -21,7 +24,7 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI | |||
21 | 24 | ||
22 | private function getTable($tableName) | 25 | private function getTable($tableName) |
23 | { | 26 | { |
24 | return $this->container->getParameter('database_table_prefix') . $tableName; | 27 | return $this->container->getParameter('database_table_prefix').$tableName; |
25 | } | 28 | } |
26 | 29 | ||
27 | /** | 30 | /** |
@@ -29,16 +32,10 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI | |||
29 | */ | 32 | */ |
30 | public function up(Schema $schema) | 33 | public function up(Schema $schema) |
31 | { | 34 | { |
32 | switch ($this->connection->getDatabasePlatform()->getName()) { | 35 | $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); |
33 | case 'sqlite': | 36 | $this->skipIf($clientsTable->hasColumn('name'), 'It seems that you already played this migration.'); |
34 | $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext DEFAULT NULL'); | 37 | |
35 | break; | 38 | $clientsTable->addColumn('name', 'blob'); |
36 | case 'mysql': | ||
37 | $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext COLLATE \'utf8_unicode_ci\' DEFAULT NULL'); | ||
38 | break; | ||
39 | case 'postgresql': | ||
40 | $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name text DEFAULT NULL'); | ||
41 | } | ||
42 | } | 39 | } |
43 | 40 | ||
44 | /** | 41 | /** |
@@ -46,8 +43,7 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI | |||
46 | */ | 43 | */ |
47 | public function down(Schema $schema) | 44 | public function down(Schema $schema) |
48 | { | 45 | { |
49 | $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); | 46 | $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); |
50 | 47 | $clientsTable->dropColumn('name'); | |
51 | $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' DROP COLUMN name'); | ||
52 | } | 48 | } |
53 | } | 49 | } |
diff --git a/app/DoctrineMigrations/Version20160911214952.php b/app/DoctrineMigrations/Version20160911214952.php index f14f7bc6..edef81ed 100644 --- a/app/DoctrineMigrations/Version20160911214952.php +++ b/app/DoctrineMigrations/Version20160911214952.php | |||
@@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; | |||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | 7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | 8 | use Symfony\Component\DependencyInjection\ContainerInterface; |
9 | 9 | ||
10 | /** | ||
11 | * Added settings for RabbitMQ and Redis imports | ||
12 | */ | ||
10 | class Version20160911214952 extends AbstractMigration implements ContainerAwareInterface | 13 | class Version20160911214952 extends AbstractMigration implements ContainerAwareInterface |
11 | { | 14 | { |
12 | /** | 15 | /** |
@@ -21,7 +24,7 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI | |||
21 | 24 | ||
22 | private function getTable($tableName) | 25 | private function getTable($tableName) |
23 | { | 26 | { |
24 | return $this->container->getParameter('database_table_prefix') . $tableName; | 27 | return $this->container->getParameter('database_table_prefix').$tableName; |
25 | } | 28 | } |
26 | 29 | ||
27 | /** | 30 | /** |
@@ -29,8 +32,25 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI | |||
29 | */ | 32 | */ |
30 | public function up(Schema $schema) | 33 | public function up(Schema $schema) |
31 | { | 34 | { |
32 | $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting').'" (name, value, section) VALUES (\'import_with_redis\', \'0\', \'import\')'); | 35 | $redis = $this->container |
33 | $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting').'" (name, value, section) VALUES (\'import_with_rabbitmq\', \'0\', \'import\')'); | 36 | ->get('doctrine.orm.default_entity_manager') |
37 | ->getConnection() | ||
38 | ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis'"); | ||
39 | |||
40 | if (false === $redis) { | ||
41 | $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_redis', 0, 'import')"); | ||
42 | } | ||
43 | |||
44 | $rabbitmq = $this->container | ||
45 | ->get('doctrine.orm.default_entity_manager') | ||
46 | ->getConnection() | ||
47 | ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq'"); | ||
48 | |||
49 | if (false === $rabbitmq) { | ||
50 | $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')"); | ||
51 | } | ||
52 | |||
53 | $this->skipIf(false !== $rabbitmq && false !== $redis, 'It seems that you already played this migration.'); | ||
34 | } | 54 | } |
35 | 55 | ||
36 | /** | 56 | /** |
@@ -38,5 +58,7 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI | |||
38 | */ | 58 | */ |
39 | public function down(Schema $schema) | 59 | public function down(Schema $schema) |
40 | { | 60 | { |
61 | $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis';"); | ||
62 | $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq';"); | ||
41 | } | 63 | } |
42 | } | 64 | } |
diff --git a/app/DoctrineMigrations/Version20160916201049.php b/app/DoctrineMigrations/Version20160916201049.php index 0d2edf9e..9f8e77e7 100644 --- a/app/DoctrineMigrations/Version20160916201049.php +++ b/app/DoctrineMigrations/Version20160916201049.php | |||
@@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema; | |||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | 7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | 8 | use Symfony\Component\DependencyInjection\ContainerInterface; |
9 | 9 | ||
10 | /** | ||
11 | * Added pocket_consumer_key field on wallabag_config | ||
12 | */ | ||
10 | class Version20160916201049 extends AbstractMigration implements ContainerAwareInterface | 13 | class Version20160916201049 extends AbstractMigration implements ContainerAwareInterface |
11 | { | 14 | { |
12 | /** | 15 | /** |
@@ -21,7 +24,7 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI | |||
21 | 24 | ||
22 | private function getTable($tableName) | 25 | private function getTable($tableName) |
23 | { | 26 | { |
24 | return $this->container->getParameter('database_table_prefix') . $tableName; | 27 | return $this->container->getParameter('database_table_prefix').$tableName; |
25 | } | 28 | } |
26 | 29 | ||
27 | /** | 30 | /** |
@@ -29,8 +32,12 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI | |||
29 | */ | 32 | */ |
30 | public function up(Schema $schema) | 33 | public function up(Schema $schema) |
31 | { | 34 | { |
32 | $this->addSql('ALTER TABLE "'.$this->getTable('config').'" ADD pocket_consumer_key VARCHAR(255) DEFAULT NULL'); | 35 | $configTable = $schema->getTable($this->getTable('config')); |
33 | $this->addSql("DELETE FROM \"".$this->getTable('craue_config_setting')."\" WHERE name = 'pocket_consumer_key';"); | 36 | |
37 | $this->skipIf($configTable->hasColumn('pocket_consumer_key'), 'It seems that you already played this migration.'); | ||
38 | |||
39 | $configTable->addColumn('pocket_consumer_key', 'string', ['notnull' => false]); | ||
40 | $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'pocket_consumer_key';"); | ||
34 | } | 41 | } |
35 | 42 | ||
36 | /** | 43 | /** |
@@ -38,9 +45,8 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI | |||
38 | */ | 45 | */ |
39 | public function down(Schema $schema) | 46 | public function down(Schema $schema) |
40 | { | 47 | { |
41 | $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); | 48 | $configTable = $schema->getTable($this->getTable('config')); |
42 | 49 | $configTable->dropColumn('pocket_consumer_key'); | |
43 | $this->addSql('ALTER TABLE "'.$this->getTable('config').'" DROP pocket_consumer_key'); | 50 | $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')"); |
44 | $this->addSql("INSERT INTO \"".$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')"); | ||
45 | } | 51 | } |
46 | } | 52 | } |
diff --git a/app/DoctrineMigrations/Version20161001072726.php b/app/DoctrineMigrations/Version20161001072726.php new file mode 100644 index 00000000..f247c236 --- /dev/null +++ b/app/DoctrineMigrations/Version20161001072726.php | |||
@@ -0,0 +1,127 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | use Doctrine\DBAL\Migrations\SkipMigrationException; | ||
10 | |||
11 | /** | ||
12 | * Added pocket_consumer_key field on wallabag_config | ||
13 | */ | ||
14 | class Version20161001072726 extends AbstractMigration implements ContainerAwareInterface | ||
15 | { | ||
16 | /** | ||
17 | * @var ContainerInterface | ||
18 | */ | ||
19 | private $container; | ||
20 | |||
21 | public function setContainer(ContainerInterface $container = null) | ||
22 | { | ||
23 | $this->container = $container; | ||
24 | } | ||
25 | |||
26 | private function getTable($tableName) | ||
27 | { | ||
28 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * @param Schema $schema | ||
33 | */ | ||
34 | public function up(Schema $schema) | ||
35 | { | ||
36 | $this->skipIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); | ||
37 | |||
38 | // remove all FK from entry_tag | ||
39 | switch ($this->connection->getDatabasePlatform()->getName()) { | ||
40 | case 'mysql': | ||
41 | $query = $this->connection->query(" | ||
42 | SELECT CONSTRAINT_NAME | ||
43 | FROM information_schema.key_column_usage | ||
44 | WHERE TABLE_NAME = '".$this->getTable('entry_tag')."' AND CONSTRAINT_NAME LIKE 'FK_%' | ||
45 | AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'" | ||
46 | ); | ||
47 | $query->execute(); | ||
48 | |||
49 | foreach ($query->fetchAll() as $fk) { | ||
50 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']); | ||
51 | } | ||
52 | break; | ||
53 | |||
54 | case 'postgresql': | ||
55 | // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk | ||
56 | $query = $this->connection->query(" | ||
57 | SELECT conrelid::regclass AS table_from | ||
58 | ,conname | ||
59 | ,pg_get_constraintdef(c.oid) | ||
60 | FROM pg_constraint c | ||
61 | JOIN pg_namespace n ON n.oid = c.connamespace | ||
62 | WHERE contype = 'f' | ||
63 | AND conrelid::regclass::text = '".$this->getTable('entry_tag')."' | ||
64 | AND n.nspname = 'public';" | ||
65 | ); | ||
66 | $query->execute(); | ||
67 | |||
68 | foreach ($query->fetchAll() as $fk) { | ||
69 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP CONSTRAINT '.$fk['conname']); | ||
70 | } | ||
71 | break; | ||
72 | } | ||
73 | |||
74 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_entry_tag_entry FOREIGN KEY (entry_id) REFERENCES '.$this->getTable('entry').' (id) ON DELETE CASCADE'); | ||
75 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_entry_tag_tag FOREIGN KEY (tag_id) REFERENCES '.$this->getTable('tag').' (id) ON DELETE CASCADE'); | ||
76 | |||
77 | // remove entry FK from annotation | ||
78 | |||
79 | switch ($this->connection->getDatabasePlatform()->getName()) { | ||
80 | case 'mysql': | ||
81 | $query = $this->connection->query(" | ||
82 | SELECT CONSTRAINT_NAME | ||
83 | FROM information_schema.key_column_usage | ||
84 | WHERE TABLE_NAME = '".$this->getTable('annotation')."' | ||
85 | AND CONSTRAINT_NAME LIKE 'FK_%' | ||
86 | AND COLUMN_NAME = 'entry_id' | ||
87 | AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'" | ||
88 | ); | ||
89 | $query->execute(); | ||
90 | |||
91 | foreach ($query->fetchAll() as $fk) { | ||
92 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']); | ||
93 | } | ||
94 | break; | ||
95 | |||
96 | case 'postgresql': | ||
97 | // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk | ||
98 | $query = $this->connection->query(" | ||
99 | SELECT conrelid::regclass AS table_from | ||
100 | ,conname | ||
101 | ,pg_get_constraintdef(c.oid) | ||
102 | FROM pg_constraint c | ||
103 | JOIN pg_namespace n ON n.oid = c.connamespace | ||
104 | WHERE contype = 'f' | ||
105 | AND conrelid::regclass::text = '".$this->getTable('annotation')."' | ||
106 | AND n.nspname = 'public' | ||
107 | AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';" | ||
108 | ); | ||
109 | $query->execute(); | ||
110 | |||
111 | foreach ($query->fetchAll() as $fk) { | ||
112 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP CONSTRAINT '.$fk['conname']); | ||
113 | } | ||
114 | break; | ||
115 | } | ||
116 | |||
117 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' ADD CONSTRAINT FK_annotation_entry FOREIGN KEY (entry_id) REFERENCES '.$this->getTable('entry').' (id) ON DELETE CASCADE'); | ||
118 | } | ||
119 | |||
120 | /** | ||
121 | * @param Schema $schema | ||
122 | */ | ||
123 | public function down(Schema $schema) | ||
124 | { | ||
125 | throw new SkipMigrationException('Too complex ...'); | ||
126 | } | ||
127 | } | ||
diff --git a/app/DoctrineMigrations/Version20161022134138.php b/app/DoctrineMigrations/Version20161022134138.php new file mode 100644 index 00000000..c71166a0 --- /dev/null +++ b/app/DoctrineMigrations/Version20161022134138.php | |||
@@ -0,0 +1,85 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Converted database to utf8mb4 encoding (for MySQL only) | ||
12 | */ | ||
13 | class Version20161022134138 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | public function setContainer(ContainerInterface $container = null) | ||
21 | { | ||
22 | $this->container = $container; | ||
23 | } | ||
24 | |||
25 | private function getTable($tableName) | ||
26 | { | ||
27 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @param Schema $schema | ||
32 | */ | ||
33 | public function up(Schema $schema) | ||
34 | { | ||
35 | $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); | ||
36 | |||
37 | $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;'); | ||
38 | |||
39 | // convert field length for utf8mb4 | ||
40 | // http://stackoverflow.com/a/31474509/569101 | ||
41 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;'); | ||
42 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE salt salt VARCHAR(180) NOT NULL;'); | ||
43 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE password password VARCHAR(180) NOT NULL;'); | ||
44 | |||
45 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
46 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
47 | $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
48 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
49 | |||
50 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
51 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
52 | |||
53 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
54 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
55 | |||
56 | $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
57 | |||
58 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * @param Schema $schema | ||
63 | */ | ||
64 | public function down(Schema $schema) | ||
65 | { | ||
66 | $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); | ||
67 | |||
68 | $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;'); | ||
69 | |||
70 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
71 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
72 | $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
73 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
74 | |||
75 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
76 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
77 | |||
78 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
79 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
80 | |||
81 | $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
82 | |||
83 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
84 | } | ||
85 | } | ||
diff --git a/app/DoctrineMigrations/Version20161024212538.php b/app/DoctrineMigrations/Version20161024212538.php new file mode 100644 index 00000000..ecb872d1 --- /dev/null +++ b/app/DoctrineMigrations/Version20161024212538.php | |||
@@ -0,0 +1,67 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Added user_id column on oauth2_clients to prevent users to delete API clients from other users | ||
12 | */ | ||
13 | class Version20161024212538 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | private $constraintName = 'IDX_user_oauth_client'; | ||
21 | |||
22 | public function setContainer(ContainerInterface $container = null) | ||
23 | { | ||
24 | $this->container = $container; | ||
25 | } | ||
26 | |||
27 | private function getTable($tableName) | ||
28 | { | ||
29 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
30 | } | ||
31 | |||
32 | /** | ||
33 | * @param Schema $schema | ||
34 | */ | ||
35 | public function up(Schema $schema) | ||
36 | { | ||
37 | $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); | ||
38 | |||
39 | $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.'); | ||
40 | |||
41 | $clientsTable->addColumn('user_id', 'integer', ['notnull' => false]); | ||
42 | |||
43 | $clientsTable->addForeignKeyConstraint( | ||
44 | $this->getTable('user'), | ||
45 | ['user_id'], | ||
46 | ['id'], | ||
47 | ['onDelete' => 'CASCADE'], | ||
48 | $this->constraintName | ||
49 | ); | ||
50 | } | ||
51 | |||
52 | /** | ||
53 | * @param Schema $schema | ||
54 | */ | ||
55 | public function down(Schema $schema) | ||
56 | { | ||
57 | $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); | ||
58 | |||
59 | $this->skipIf(!$clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.'); | ||
60 | |||
61 | $clientsTable->dropColumn('user_id', 'integer'); | ||
62 | |||
63 | if ($this->connection->getDatabasePlatform()->getName() != 'sqlite') { | ||
64 | $clientsTable->removeForeignKey($this->constraintName); | ||
65 | } | ||
66 | } | ||
67 | } | ||
diff --git a/app/DoctrineMigrations/Version20161031132655.php b/app/DoctrineMigrations/Version20161031132655.php new file mode 100644 index 00000000..83b97ca9 --- /dev/null +++ b/app/DoctrineMigrations/Version20161031132655.php | |||
@@ -0,0 +1,52 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Added the internal setting to enable/disable downloading pictures | ||
12 | */ | ||
13 | class Version20161031132655 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | public function setContainer(ContainerInterface $container = null) | ||
21 | { | ||
22 | $this->container = $container; | ||
23 | } | ||
24 | |||
25 | private function getTable($tableName) | ||
26 | { | ||
27 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @param Schema $schema | ||
32 | */ | ||
33 | public function up(Schema $schema) | ||
34 | { | ||
35 | $images = $this->container | ||
36 | ->get('doctrine.orm.default_entity_manager') | ||
37 | ->getConnection() | ||
38 | ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled'"); | ||
39 | |||
40 | $this->skipIf(false !== $images, 'It seems that you already played this migration.'); | ||
41 | |||
42 | $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('download_images_enabled', 0, 'misc')"); | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * @param Schema $schema | ||
47 | */ | ||
48 | public function down(Schema $schema) | ||
49 | { | ||
50 | $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled';"); | ||
51 | } | ||
52 | } | ||
diff --git a/app/DoctrineMigrations/Version20161104073720.php b/app/DoctrineMigrations/Version20161104073720.php new file mode 100644 index 00000000..fb8f5fa1 --- /dev/null +++ b/app/DoctrineMigrations/Version20161104073720.php | |||
@@ -0,0 +1,53 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Added created_at index on entry table | ||
12 | */ | ||
13 | class Version20161104073720 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | private $indexName = 'IDX_entry_created_at'; | ||
21 | |||
22 | public function setContainer(ContainerInterface $container = null) | ||
23 | { | ||
24 | $this->container = $container; | ||
25 | } | ||
26 | |||
27 | private function getTable($tableName) | ||
28 | { | ||
29 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
30 | } | ||
31 | |||
32 | /** | ||
33 | * @param Schema $schema | ||
34 | */ | ||
35 | public function up(Schema $schema) | ||
36 | { | ||
37 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
38 | $this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.'); | ||
39 | |||
40 | $entryTable->addIndex(['created_at'], $this->indexName); | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * @param Schema $schema | ||
45 | */ | ||
46 | public function down(Schema $schema) | ||
47 | { | ||
48 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
49 | $this->skipIf(false === $entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.'); | ||
50 | |||
51 | $entryTable->dropIndex($this->indexName); | ||
52 | } | ||
53 | } | ||
diff --git a/app/DoctrineMigrations/Version20161106113822.php b/app/DoctrineMigrations/Version20161106113822.php new file mode 100644 index 00000000..de3702a4 --- /dev/null +++ b/app/DoctrineMigrations/Version20161106113822.php | |||
@@ -0,0 +1,56 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Added action_mark_as_read field on config table | ||
12 | */ | ||
13 | class Version20161106113822 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | public function setContainer(ContainerInterface $container = null) | ||
21 | { | ||
22 | $this->container = $container; | ||
23 | } | ||
24 | |||
25 | private function getTable($tableName) | ||
26 | { | ||
27 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @param Schema $schema | ||
32 | */ | ||
33 | public function up(Schema $schema) | ||
34 | { | ||
35 | $configTable = $schema->getTable($this->getTable('config')); | ||
36 | |||
37 | $this->skipIf($configTable->hasColumn('action_mark_as_read'), 'It seems that you already played this migration.'); | ||
38 | |||
39 | $configTable->addColumn('action_mark_as_read', 'integer', [ | ||
40 | 'default' => 0, | ||
41 | 'notnull' => false, | ||
42 | ]); | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * @param Schema $schema | ||
47 | */ | ||
48 | public function down(Schema $schema) | ||
49 | { | ||
50 | $configTable = $schema->getTable($this->getTable('config')); | ||
51 | |||
52 | $this->skipIf(!$configTable->hasColumn('action_mark_as_read'), 'It seems that you already played this migration.'); | ||
53 | |||
54 | $configTable->dropColumn('action_mark_as_read'); | ||
55 | } | ||
56 | } | ||
diff --git a/app/DoctrineMigrations/Version20161117071626.php b/app/DoctrineMigrations/Version20161117071626.php new file mode 100644 index 00000000..8daa2142 --- /dev/null +++ b/app/DoctrineMigrations/Version20161117071626.php | |||
@@ -0,0 +1,64 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Added the internal setting to share articles to unmark.it | ||
12 | */ | ||
13 | class Version20161117071626 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | public function setContainer(ContainerInterface $container = null) | ||
21 | { | ||
22 | $this->container = $container; | ||
23 | } | ||
24 | |||
25 | private function getTable($tableName) | ||
26 | { | ||
27 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @param Schema $schema | ||
32 | */ | ||
33 | public function up(Schema $schema) | ||
34 | { | ||
35 | $share = $this->container | ||
36 | ->get('doctrine.orm.default_entity_manager') | ||
37 | ->getConnection() | ||
38 | ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark'"); | ||
39 | |||
40 | if (false === $share) { | ||
41 | $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')"); | ||
42 | } | ||
43 | |||
44 | $unmark = $this->container | ||
45 | ->get('doctrine.orm.default_entity_manager') | ||
46 | ->getConnection() | ||
47 | ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url'"); | ||
48 | |||
49 | if (false === $unmark) { | ||
50 | $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')"); | ||
51 | } | ||
52 | |||
53 | $this->skipIf(false !== $share && false !== $unmark, 'It seems that you already played this migration.'); | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * @param Schema $schema | ||
58 | */ | ||
59 | public function down(Schema $schema) | ||
60 | { | ||
61 | $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark';"); | ||
62 | $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url';"); | ||
63 | } | ||
64 | } | ||
diff --git a/app/DoctrineMigrations/Version20161118134328.php b/app/DoctrineMigrations/Version20161118134328.php new file mode 100644 index 00000000..7b2eeb7b --- /dev/null +++ b/app/DoctrineMigrations/Version20161118134328.php | |||
@@ -0,0 +1,56 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Add http_status in `entry_table`. | ||
12 | */ | ||
13 | class Version20161118134328 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | public function setContainer(ContainerInterface $container = null) | ||
21 | { | ||
22 | $this->container = $container; | ||
23 | } | ||
24 | |||
25 | private function getTable($tableName) | ||
26 | { | ||
27 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @param Schema $schema | ||
32 | */ | ||
33 | public function up(Schema $schema) | ||
34 | { | ||
35 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
36 | |||
37 | $this->skipIf($entryTable->hasColumn('http_status'), 'It seems that you already played this migration.'); | ||
38 | |||
39 | $entryTable->addColumn('http_status', 'string', [ | ||
40 | 'length' => 3, | ||
41 | 'notnull' => false, | ||
42 | ]); | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * @param Schema $schema | ||
47 | */ | ||
48 | public function down(Schema $schema) | ||
49 | { | ||
50 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
51 | |||
52 | $this->skipIf(!$entryTable->hasColumn('http_status'), 'It seems that you already played this migration.'); | ||
53 | |||
54 | $entryTable->dropColumn('http_status'); | ||
55 | } | ||
56 | } | ||
diff --git a/app/DoctrineMigrations/Version20161122144743.php b/app/DoctrineMigrations/Version20161122144743.php new file mode 100644 index 00000000..388a0e4b --- /dev/null +++ b/app/DoctrineMigrations/Version20161122144743.php | |||
@@ -0,0 +1,52 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Add the restricted_access internal setting for articles with paywall. | ||
12 | */ | ||
13 | class Version20161122144743 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | public function setContainer(ContainerInterface $container = null) | ||
21 | { | ||
22 | $this->container = $container; | ||
23 | } | ||
24 | |||
25 | private function getTable($tableName) | ||
26 | { | ||
27 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @param Schema $schema | ||
32 | */ | ||
33 | public function up(Schema $schema) | ||
34 | { | ||
35 | $access = $this->container | ||
36 | ->get('doctrine.orm.default_entity_manager') | ||
37 | ->getConnection() | ||
38 | ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'restricted_access'"); | ||
39 | |||
40 | $this->skipIf(false !== $access, 'It seems that you already played this migration.'); | ||
41 | |||
42 | $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')"); | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | * @param Schema $schema | ||
47 | */ | ||
48 | public function down(Schema $schema) | ||
49 | { | ||
50 | $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'restricted_access';"); | ||
51 | } | ||
52 | } | ||
diff --git a/app/DoctrineMigrations/Version20161122203647.php b/app/DoctrineMigrations/Version20161122203647.php new file mode 100644 index 00000000..9b17d6ef --- /dev/null +++ b/app/DoctrineMigrations/Version20161122203647.php | |||
@@ -0,0 +1,63 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Methods and properties removed from `FOS\UserBundle\Model\User`. | ||
12 | * | ||
13 | * - `$expired` | ||
14 | * - `$credentialsExpired` | ||
15 | * - `setExpired()` (use `setExpiresAt(\DateTime::now()` instead) | ||
16 | * - `setCredentialsExpired()` (use `setCredentialsExpireAt(\DateTime::now()` instead) | ||
17 | * | ||
18 | * You need to drop the fields `expired` and `credentials_expired` from your database | ||
19 | * schema, because they aren't mapped anymore. | ||
20 | */ | ||
21 | class Version20161122203647 extends AbstractMigration implements ContainerAwareInterface | ||
22 | { | ||
23 | /** | ||
24 | * @var ContainerInterface | ||
25 | */ | ||
26 | private $container; | ||
27 | |||
28 | public function setContainer(ContainerInterface $container = null) | ||
29 | { | ||
30 | $this->container = $container; | ||
31 | } | ||
32 | |||
33 | private function getTable($tableName) | ||
34 | { | ||
35 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
36 | } | ||
37 | |||
38 | /** | ||
39 | * @param Schema $schema | ||
40 | */ | ||
41 | public function up(Schema $schema) | ||
42 | { | ||
43 | $userTable = $schema->getTable($this->getTable('user')); | ||
44 | |||
45 | $this->skipIf(false === $userTable->hasColumn('expired') || false === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.'); | ||
46 | |||
47 | $userTable->dropColumn('expired'); | ||
48 | $userTable->dropColumn('credentials_expired'); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * @param Schema $schema | ||
53 | */ | ||
54 | public function down(Schema $schema) | ||
55 | { | ||
56 | $userTable = $schema->getTable($this->getTable('user')); | ||
57 | |||
58 | $this->skipIf(true === $userTable->hasColumn('expired') || true === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.'); | ||
59 | |||
60 | $userTable->addColumn('expired', 'smallint', ['notnull' => false]); | ||
61 | $userTable->addColumn('credentials_expired', 'smallint', ['notnull' => false]); | ||
62 | } | ||
63 | } | ||
diff --git a/app/DoctrineMigrations/Version20161128084725.php b/app/DoctrineMigrations/Version20161128084725.php new file mode 100644 index 00000000..ea370076 --- /dev/null +++ b/app/DoctrineMigrations/Version20161128084725.php | |||
@@ -0,0 +1,49 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Added list_mode in user config. | ||
12 | */ | ||
13 | class Version20161128084725 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | public function setContainer(ContainerInterface $container = null) | ||
21 | { | ||
22 | $this->container = $container; | ||
23 | } | ||
24 | |||
25 | private function getTable($tableName) | ||
26 | { | ||
27 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @param Schema $schema | ||
32 | */ | ||
33 | public function up(Schema $schema) | ||
34 | { | ||
35 | $configTable = $schema->getTable($this->getTable('config')); | ||
36 | $this->skipIf($configTable->hasColumn('list_mode'), 'It seems that you already played this migration.'); | ||
37 | |||
38 | $configTable->addColumn('list_mode', 'integer', ['notnull' => false]); | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * @param Schema $schema | ||
43 | */ | ||
44 | public function down(Schema $schema) | ||
45 | { | ||
46 | $configTable = $schema->getTable($this->getTable('config')); | ||
47 | $configTable->dropColumn('list_mode'); | ||
48 | } | ||
49 | } | ||
diff --git a/app/DoctrineMigrations/Version20161128131503.php b/app/DoctrineMigrations/Version20161128131503.php new file mode 100644 index 00000000..b71aa38b --- /dev/null +++ b/app/DoctrineMigrations/Version20161128131503.php | |||
@@ -0,0 +1,61 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Removed locked, credentials_expire_at and expires_at. | ||
12 | */ | ||
13 | class Version20161128131503 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | private $fields = [ | ||
16 | 'locked' => 'smallint', | ||
17 | 'credentials_expire_at' => 'datetime', | ||
18 | 'expires_at' => 'datetime', | ||
19 | ]; | ||
20 | |||
21 | /** | ||
22 | * @var ContainerInterface | ||
23 | */ | ||
24 | private $container; | ||
25 | |||
26 | public function setContainer(ContainerInterface $container = null) | ||
27 | { | ||
28 | $this->container = $container; | ||
29 | } | ||
30 | |||
31 | private function getTable($tableName) | ||
32 | { | ||
33 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
34 | } | ||
35 | |||
36 | /** | ||
37 | * @param Schema $schema | ||
38 | */ | ||
39 | public function up(Schema $schema) | ||
40 | { | ||
41 | $userTable = $schema->getTable($this->getTable('user')); | ||
42 | |||
43 | foreach ($this->fields as $field => $type) { | ||
44 | $this->skipIf(!$userTable->hasColumn($field), 'It seems that you already played this migration.'); | ||
45 | $userTable->dropColumn($field); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @param Schema $schema | ||
51 | */ | ||
52 | public function down(Schema $schema) | ||
53 | { | ||
54 | $userTable = $schema->getTable($this->getTable('user')); | ||
55 | |||
56 | foreach ($this->fields as $field => $type) { | ||
57 | $this->skipIf($userTable->hasColumn($field), 'It seems that you already played this migration.'); | ||
58 | $userTable->addColumn($field, $type, ['notnull' => false]); | ||
59 | } | ||
60 | } | ||
61 | } | ||
diff --git a/app/DoctrineMigrations/Version20161214094402.php b/app/DoctrineMigrations/Version20161214094402.php new file mode 100644 index 00000000..db125f76 --- /dev/null +++ b/app/DoctrineMigrations/Version20161214094402.php | |||
@@ -0,0 +1,75 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Renamed uuid to uid in entry table | ||
12 | */ | ||
13 | class Version20161214094402 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | public function setContainer(ContainerInterface $container = null) | ||
21 | { | ||
22 | $this->container = $container; | ||
23 | } | ||
24 | |||
25 | private function getTable($tableName) | ||
26 | { | ||
27 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
28 | } | ||
29 | |||
30 | /** | ||
31 | * @param Schema $schema | ||
32 | */ | ||
33 | public function up(Schema $schema) | ||
34 | { | ||
35 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
36 | |||
37 | $this->skipIf($entryTable->hasColumn('uid'), 'It seems that you already played this migration.'); | ||
38 | |||
39 | switch ($this->connection->getDatabasePlatform()->getName()) { | ||
40 | case 'sqlite': | ||
41 | $this->addSql('CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM '.$this->getTable('entry')); | ||
42 | $this->addSql('DROP TABLE '.$this->getTable('entry')); | ||
43 | $this->addSql('CREATE TABLE '.$this->getTable('entry').' (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid CLOB DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT "0", PRIMARY KEY(id));'); | ||
44 | $this->addSql('INSERT INTO '.$this->getTable('entry').' (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public) SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM __temp__wallabag_entry;'); | ||
45 | $this->addSql('DROP TABLE __temp__wallabag_entry'); | ||
46 | break; | ||
47 | case 'mysql': | ||
48 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE uuid uid VARCHAR(23)'); | ||
49 | break; | ||
50 | case 'postgresql': | ||
51 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' RENAME uuid TO uid'); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @param Schema $schema | ||
57 | */ | ||
58 | public function down(Schema $schema) | ||
59 | { | ||
60 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
61 | |||
62 | $this->skipIf($entryTable->hasColumn('uuid'), 'It seems that you already played this migration.'); | ||
63 | |||
64 | switch ($this->connection->getDatabasePlatform()->getName()) { | ||
65 | case 'sqlite': | ||
66 | throw new SkipMigrationException('Too complex ...'); | ||
67 | break; | ||
68 | case 'mysql': | ||
69 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE uid uuid VARCHAR(23)'); | ||
70 | break; | ||
71 | case 'postgresql': | ||
72 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' RENAME uid TO uuid'); | ||
73 | } | ||
74 | } | ||
75 | } | ||
diff --git a/app/DoctrineMigrations/Version20161214094403.php b/app/DoctrineMigrations/Version20161214094403.php new file mode 100644 index 00000000..5948b5fa --- /dev/null +++ b/app/DoctrineMigrations/Version20161214094403.php | |||
@@ -0,0 +1,53 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Added index on wallabag_entry.uid | ||
12 | */ | ||
13 | class Version20161214094403 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | /** | ||
16 | * @var ContainerInterface | ||
17 | */ | ||
18 | private $container; | ||
19 | |||
20 | private $indexName = 'IDX_entry_uid'; | ||
21 | |||
22 | public function setContainer(ContainerInterface $container = null) | ||
23 | { | ||
24 | $this->container = $container; | ||
25 | } | ||
26 | |||
27 | private function getTable($tableName) | ||
28 | { | ||
29 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
30 | } | ||
31 | |||
32 | /** | ||
33 | * @param Schema $schema | ||
34 | */ | ||
35 | public function up(Schema $schema) | ||
36 | { | ||
37 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
38 | $this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.'); | ||
39 | |||
40 | $entryTable->addIndex(['uid'], $this->indexName); | ||
41 | } | ||
42 | |||
43 | /** | ||
44 | * @param Schema $schema | ||
45 | */ | ||
46 | public function down(Schema $schema) | ||
47 | { | ||
48 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
49 | $this->skipIf(false === $entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.'); | ||
50 | |||
51 | $entryTable->dropIndex($this->indexName); | ||
52 | } | ||
53 | } | ||