aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations
diff options
context:
space:
mode:
Diffstat (limited to 'app/DoctrineMigrations')
-rw-r--r--app/DoctrineMigrations/Version20160410190541.php22
-rw-r--r--app/DoctrineMigrations/Version20160812120952.php21
-rw-r--r--app/DoctrineMigrations/Version20160911214952.php25
-rw-r--r--app/DoctrineMigrations/Version20160916201049.php17
-rw-r--r--app/DoctrineMigrations/Version20161001072726.php123
-rw-r--r--app/DoctrineMigrations/Version20161022134138.php82
-rw-r--r--app/DoctrineMigrations/Version20161024212538.php52
-rw-r--r--app/DoctrineMigrations/Version20161031132655.php49
-rw-r--r--app/DoctrineMigrations/Version20161104073720.php50
-rw-r--r--app/DoctrineMigrations/Version20161106113822.php50
-rw-r--r--app/DoctrineMigrations/Version20161117071626.php61
-rw-r--r--app/DoctrineMigrations/Version20161118134328.php53
-rw-r--r--app/DoctrineMigrations/Version20161122144743.php52
-rw-r--r--app/DoctrineMigrations/Version20161122203647.php60
-rw-r--r--app/DoctrineMigrations/Version20161128084725.php49
-rw-r--r--app/DoctrineMigrations/Version20161128131503.php61
-rw-r--r--app/DoctrineMigrations/Version20161214094403.php53
17 files changed, 846 insertions, 34 deletions
diff --git a/app/DoctrineMigrations/Version20160410190541.php b/app/DoctrineMigrations/Version20160410190541.php
index f034b0e4..f166a325 100644
--- a/app/DoctrineMigrations/Version20160410190541.php
+++ b/app/DoctrineMigrations/Version20160410190541.php
@@ -21,7 +21,7 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
21 21
22 private function getTable($tableName) 22 private function getTable($tableName)
23 { 23 {
24 return $this->container->getParameter('database_table_prefix') . $tableName; 24 return $this->container->getParameter('database_table_prefix').$tableName;
25 } 25 }
26 26
27 /** 27 /**
@@ -29,13 +29,15 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
29 */ 29 */
30 public function up(Schema $schema) 30 public function up(Schema $schema)
31 { 31 {
32 if ($this->connection->getDatabasePlatform()->getName() == 'postgresql') { 32 $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 33
38 $this->addSql("INSERT INTO \"".$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('share_public', '1', 'entry')"); 34 $this->skipIf($entryTable->hasColumn('uid'), 'It seems that you already played this migration.');
35
36 $entryTable->addColumn('uid', 'string', [
37 'notnull' => false,
38 'length' => 23,
39 ]);
40 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_public', '1', 'entry')");
39 } 41 }
40 42
41 /** 43 /**
@@ -43,9 +45,9 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
43 */ 45 */
44 public function down(Schema $schema) 46 public function down(Schema $schema)
45 { 47 {
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.'); 48 $entryTable = $schema->getTable($this->getTable('entry'));
49 $entryTable->dropColumn('uid');
47 50
48 $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" DROP uuid'); 51 $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 } 52 }
51} 53}
diff --git a/app/DoctrineMigrations/Version20160812120952.php b/app/DoctrineMigrations/Version20160812120952.php
index 3aafea64..053b8d88 100644
--- a/app/DoctrineMigrations/Version20160812120952.php
+++ b/app/DoctrineMigrations/Version20160812120952.php
@@ -21,7 +21,7 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
21 21
22 private function getTable($tableName) 22 private function getTable($tableName)
23 { 23 {
24 return $this->container->getParameter('database_table_prefix') . $tableName; 24 return $this->container->getParameter('database_table_prefix').$tableName;
25 } 25 }
26 26
27 /** 27 /**
@@ -29,16 +29,10 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
29 */ 29 */
30 public function up(Schema $schema) 30 public function up(Schema $schema)
31 { 31 {
32 switch ($this->connection->getDatabasePlatform()->getName()) { 32 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
33 case 'sqlite': 33 $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'); 34
35 break; 35 $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 } 36 }
43 37
44 /** 38 /**
@@ -46,8 +40,7 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
46 */ 40 */
47 public function down(Schema $schema) 41 public function down(Schema $schema)
48 { 42 {
49 $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); 43 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
50 44 $clientsTable->dropColumn('name');
51 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' DROP COLUMN name');
52 } 45 }
53} 46}
diff --git a/app/DoctrineMigrations/Version20160911214952.php b/app/DoctrineMigrations/Version20160911214952.php
index f14f7bc6..6ddeb767 100644
--- a/app/DoctrineMigrations/Version20160911214952.php
+++ b/app/DoctrineMigrations/Version20160911214952.php
@@ -21,7 +21,7 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
21 21
22 private function getTable($tableName) 22 private function getTable($tableName)
23 { 23 {
24 return $this->container->getParameter('database_table_prefix') . $tableName; 24 return $this->container->getParameter('database_table_prefix').$tableName;
25 } 25 }
26 26
27 /** 27 /**
@@ -29,8 +29,25 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
29 */ 29 */
30 public function up(Schema $schema) 30 public function up(Schema $schema)
31 { 31 {
32 $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting').'" (name, value, section) VALUES (\'import_with_redis\', \'0\', \'import\')'); 32 $redis = $this->container
33 $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting').'" (name, value, section) VALUES (\'import_with_rabbitmq\', \'0\', \'import\')'); 33 ->get('doctrine.orm.default_entity_manager')
34 ->getConnection()
35 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis'");
36
37 if (false === $redis) {
38 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_redis', 0, 'import')");
39 }
40
41 $rabbitmq = $this->container
42 ->get('doctrine.orm.default_entity_manager')
43 ->getConnection()
44 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq'");
45
46 if (false === $rabbitmq) {
47 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')");
48 }
49
50 $this->skipIf(false !== $rabbitmq && false !== $redis, 'It seems that you already played this migration.');
34 } 51 }
35 52
36 /** 53 /**
@@ -38,5 +55,7 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
38 */ 55 */
39 public function down(Schema $schema) 56 public function down(Schema $schema)
40 { 57 {
58 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis';");
59 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq';");
41 } 60 }
42} 61}
diff --git a/app/DoctrineMigrations/Version20160916201049.php b/app/DoctrineMigrations/Version20160916201049.php
index 0d2edf9e..8b42bb87 100644
--- a/app/DoctrineMigrations/Version20160916201049.php
+++ b/app/DoctrineMigrations/Version20160916201049.php
@@ -21,7 +21,7 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
21 21
22 private function getTable($tableName) 22 private function getTable($tableName)
23 { 23 {
24 return $this->container->getParameter('database_table_prefix') . $tableName; 24 return $this->container->getParameter('database_table_prefix').$tableName;
25 } 25 }
26 26
27 /** 27 /**
@@ -29,8 +29,12 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
29 */ 29 */
30 public function up(Schema $schema) 30 public function up(Schema $schema)
31 { 31 {
32 $this->addSql('ALTER TABLE "'.$this->getTable('config').'" ADD pocket_consumer_key VARCHAR(255) DEFAULT NULL'); 32 $configTable = $schema->getTable($this->getTable('config'));
33 $this->addSql("DELETE FROM \"".$this->getTable('craue_config_setting')."\" WHERE name = 'pocket_consumer_key';"); 33
34 $this->skipIf($configTable->hasColumn('pocket_consumer_key'), 'It seems that you already played this migration.');
35
36 $configTable->addColumn('pocket_consumer_key', 'string', ['notnull' => false]);
37 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'pocket_consumer_key';");
34 } 38 }
35 39
36 /** 40 /**
@@ -38,9 +42,8 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
38 */ 42 */
39 public function down(Schema $schema) 43 public function down(Schema $schema)
40 { 44 {
41 $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); 45 $configTable = $schema->getTable($this->getTable('config'));
42 46 $configTable->dropColumn('pocket_consumer_key');
43 $this->addSql('ALTER TABLE "'.$this->getTable('config').'" DROP pocket_consumer_key'); 47 $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 } 48 }
46} 49}
diff --git a/app/DoctrineMigrations/Version20161001072726.php b/app/DoctrineMigrations/Version20161001072726.php
new file mode 100644
index 00000000..f6930778
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161001072726.php
@@ -0,0 +1,123 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10class Version20161001072726 extends AbstractMigration implements ContainerAwareInterface
11{
12 /**
13 * @var ContainerInterface
14 */
15 private $container;
16
17 public function setContainer(ContainerInterface $container = null)
18 {
19 $this->container = $container;
20 }
21
22 private function getTable($tableName)
23 {
24 return $this->container->getParameter('database_table_prefix').$tableName;
25 }
26
27 /**
28 * @param Schema $schema
29 */
30 public function up(Schema $schema)
31 {
32 $this->skipIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
33
34 // remove all FK from entry_tag
35 switch ($this->connection->getDatabasePlatform()->getName()) {
36 case 'mysql':
37 $query = $this->connection->query("
38 SELECT CONSTRAINT_NAME
39 FROM information_schema.key_column_usage
40 WHERE TABLE_NAME = '".$this->getTable('entry_tag')."' AND CONSTRAINT_NAME LIKE 'FK_%'
41 AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'"
42 );
43 $query->execute();
44
45 foreach ($query->fetchAll() as $fk) {
46 $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']);
47 }
48 break;
49
50 case 'postgresql':
51 // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk
52 $query = $this->connection->query("
53 SELECT conrelid::regclass AS table_from
54 ,conname
55 ,pg_get_constraintdef(c.oid)
56 FROM pg_constraint c
57 JOIN pg_namespace n ON n.oid = c.connamespace
58 WHERE contype = 'f'
59 AND conrelid::regclass::text = '".$this->getTable('entry_tag')."'
60 AND n.nspname = 'public';"
61 );
62 $query->execute();
63
64 foreach ($query->fetchAll() as $fk) {
65 $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP CONSTRAINT '.$fk['conname']);
66 }
67 break;
68 }
69
70 $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');
71 $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');
72
73 // remove entry FK from annotation
74
75 switch ($this->connection->getDatabasePlatform()->getName()) {
76 case 'mysql':
77 $query = $this->connection->query("
78 SELECT CONSTRAINT_NAME
79 FROM information_schema.key_column_usage
80 WHERE TABLE_NAME = '".$this->getTable('annotation')."'
81 AND CONSTRAINT_NAME LIKE 'FK_%'
82 AND COLUMN_NAME = 'entry_id'
83 AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'"
84 );
85 $query->execute();
86
87 foreach ($query->fetchAll() as $fk) {
88 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']);
89 }
90 break;
91
92 case 'postgresql':
93 // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk
94 $query = $this->connection->query("
95 SELECT conrelid::regclass AS table_from
96 ,conname
97 ,pg_get_constraintdef(c.oid)
98 FROM pg_constraint c
99 JOIN pg_namespace n ON n.oid = c.connamespace
100 WHERE contype = 'f'
101 AND conrelid::regclass::text = '".$this->getTable('annotation')."'
102 AND n.nspname = 'public'
103 AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';"
104 );
105 $query->execute();
106
107 foreach ($query->fetchAll() as $fk) {
108 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP CONSTRAINT '.$fk['conname']);
109 }
110 break;
111 }
112
113 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' ADD CONSTRAINT FK_annotation_entry FOREIGN KEY (entry_id) REFERENCES '.$this->getTable('entry').' (id) ON DELETE CASCADE');
114 }
115
116 /**
117 * @param Schema $schema
118 */
119 public function down(Schema $schema)
120 {
121 throw new SkipMigrationException('Too complex ...');
122 }
123}
diff --git a/app/DoctrineMigrations/Version20161022134138.php b/app/DoctrineMigrations/Version20161022134138.php
new file mode 100644
index 00000000..d0e5cb3f
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161022134138.php
@@ -0,0 +1,82 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10class Version20161022134138 extends AbstractMigration implements ContainerAwareInterface
11{
12 /**
13 * @var ContainerInterface
14 */
15 private $container;
16
17 public function setContainer(ContainerInterface $container = null)
18 {
19 $this->container = $container;
20 }
21
22 private function getTable($tableName)
23 {
24 return $this->container->getParameter('database_table_prefix').$tableName;
25 }
26
27 /**
28 * @param Schema $schema
29 */
30 public function up(Schema $schema)
31 {
32 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
33
34 $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
35
36 // convert field length for utf8mb4
37 // http://stackoverflow.com/a/31474509/569101
38 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;');
39 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE salt salt VARCHAR(180) NOT NULL;');
40 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE password password VARCHAR(180) NOT NULL;');
41
42 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
43 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
44 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
45 $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
46
47 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
48 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
49
50 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
51 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
52
53 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
54
55 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
56 }
57
58 /**
59 * @param Schema $schema
60 */
61 public function down(Schema $schema)
62 {
63 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
64
65 $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
66
67 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
68 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
69 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
70 $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
71
72 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
73 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
74
75 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
76 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
77
78 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
79
80 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
81 }
82}
diff --git a/app/DoctrineMigrations/Version20161024212538.php b/app/DoctrineMigrations/Version20161024212538.php
new file mode 100644
index 00000000..75ff86f1
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161024212538.php
@@ -0,0 +1,52 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10class Version20161024212538 extends AbstractMigration implements ContainerAwareInterface
11{
12 /**
13 * @var ContainerInterface
14 */
15 private $container;
16
17 public function setContainer(ContainerInterface $container = null)
18 {
19 $this->container = $container;
20 }
21
22 private function getTable($tableName)
23 {
24 return $this->container->getParameter('database_table_prefix').$tableName;
25 }
26
27 /**
28 * @param Schema $schema
29 */
30 public function up(Schema $schema)
31 {
32 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
33
34 $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
35
36 $clientsTable->addColumn('user_id', 'integer');
37
38 $clientsTable->addForeignKeyConstraint(
39 $this->getTable('user'),
40 ['user_id'],
41 ['id'],
42 ['onDelete' => 'CASCADE']
43 );
44 }
45
46 /**
47 * @param Schema $schema
48 */
49 public function down(Schema $schema)
50 {
51 }
52}
diff --git a/app/DoctrineMigrations/Version20161031132655.php b/app/DoctrineMigrations/Version20161031132655.php
new file mode 100644
index 00000000..f81898ff
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161031132655.php
@@ -0,0 +1,49 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10class Version20161031132655 extends AbstractMigration implements ContainerAwareInterface
11{
12 /**
13 * @var ContainerInterface
14 */
15 private $container;
16
17 public function setContainer(ContainerInterface $container = null)
18 {
19 $this->container = $container;
20 }
21
22 private function getTable($tableName)
23 {
24 return $this->container->getParameter('database_table_prefix').$tableName;
25 }
26
27 /**
28 * @param Schema $schema
29 */
30 public function up(Schema $schema)
31 {
32 $images = $this->container
33 ->get('doctrine.orm.default_entity_manager')
34 ->getConnection()
35 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled'");
36
37 $this->skipIf(false !== $images, 'It seems that you already played this migration.');
38
39 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
40 }
41
42 /**
43 * @param Schema $schema
44 */
45 public function down(Schema $schema)
46 {
47 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled';");
48 }
49}
diff --git a/app/DoctrineMigrations/Version20161104073720.php b/app/DoctrineMigrations/Version20161104073720.php
new file mode 100644
index 00000000..4721426a
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161104073720.php
@@ -0,0 +1,50 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10class Version20161104073720 extends AbstractMigration implements ContainerAwareInterface
11{
12 /**
13 * @var ContainerInterface
14 */
15 private $container;
16
17 private $indexName = 'IDX_entry_created_at';
18
19 public function setContainer(ContainerInterface $container = null)
20 {
21 $this->container = $container;
22 }
23
24 private function getTable($tableName)
25 {
26 return $this->container->getParameter('database_table_prefix').$tableName;
27 }
28
29 /**
30 * @param Schema $schema
31 */
32 public function up(Schema $schema)
33 {
34 $entryTable = $schema->getTable($this->getTable('entry'));
35 $this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
36
37 $entryTable->addIndex(['created_at'], $this->indexName);
38 }
39
40 /**
41 * @param Schema $schema
42 */
43 public function down(Schema $schema)
44 {
45 $entryTable = $schema->getTable($this->getTable('entry'));
46 $this->skipIf(false === $entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
47
48 $entryTable->dropIndex($this->indexName);
49 }
50}
diff --git a/app/DoctrineMigrations/Version20161106113822.php b/app/DoctrineMigrations/Version20161106113822.php
new file mode 100644
index 00000000..55bd87a2
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161106113822.php
@@ -0,0 +1,50 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10class Version20161106113822 extends AbstractMigration implements ContainerAwareInterface
11{
12 /**
13 * @var ContainerInterface
14 */
15 private $container;
16
17 public function setContainer(ContainerInterface $container = null)
18 {
19 $this->container = $container;
20 }
21
22 private function getTable($tableName)
23 {
24 return $this->container->getParameter('database_table_prefix').$tableName;
25 }
26
27 /**
28 * @param Schema $schema
29 */
30 public function up(Schema $schema)
31 {
32 $configTable = $schema->getTable($this->getTable('config'));
33
34 $this->skipIf($configTable->hasColumn('action_mark_as_read'), 'It seems that you already played this migration.');
35
36 $configTable->addColumn('action_mark_as_read', 'integer', [
37 'default' => 0,
38 'notnull' => false,
39 ]);
40 }
41
42 /**
43 * @param Schema $schema
44 */
45 public function down(Schema $schema)
46 {
47 $configTable = $schema->getTable($this->getTable('config'));
48 $userTable->dropColumn('action_mark_as_read');
49 }
50}
diff --git a/app/DoctrineMigrations/Version20161117071626.php b/app/DoctrineMigrations/Version20161117071626.php
new file mode 100644
index 00000000..d864888f
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161117071626.php
@@ -0,0 +1,61 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10class Version20161117071626 extends AbstractMigration implements ContainerAwareInterface
11{
12 /**
13 * @var ContainerInterface
14 */
15 private $container;
16
17 public function setContainer(ContainerInterface $container = null)
18 {
19 $this->container = $container;
20 }
21
22 private function getTable($tableName)
23 {
24 return $this->container->getParameter('database_table_prefix').$tableName;
25 }
26
27 /**
28 * @param Schema $schema
29 */
30 public function up(Schema $schema)
31 {
32 $share = $this->container
33 ->get('doctrine.orm.default_entity_manager')
34 ->getConnection()
35 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark'");
36
37 if (false === $share) {
38 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')");
39 }
40
41 $unmark = $this->container
42 ->get('doctrine.orm.default_entity_manager')
43 ->getConnection()
44 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url'");
45
46 if (false === $unmark) {
47 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
48 }
49
50 $this->skipIf(false !== $share && false !== $unmark, 'It seems that you already played this migration.');
51 }
52
53 /**
54 * @param Schema $schema
55 */
56 public function down(Schema $schema)
57 {
58 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark';");
59 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url';");
60 }
61}
diff --git a/app/DoctrineMigrations/Version20161118134328.php b/app/DoctrineMigrations/Version20161118134328.php
new file mode 100644
index 00000000..f168cb53
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161118134328.php
@@ -0,0 +1,53 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add http_status in `entry_table`.
12 */
13class 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 $userTable = $schema->getTable($this->getTable('entry'));
51 $userTable->dropColumn('http_status');
52 }
53}
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
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add the restricted_access internal setting for articles with paywall.
12 */
13class 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..94197193
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161122203647.php
@@ -0,0 +1,60 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use 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 */
21class 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 $userTable->addColumn('expired', 'smallint');
58 $userTable->addColumn('credentials_expired', 'smallint');
59 }
60}
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
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Added list_mode in user config.
12 */
13class 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..f0e016c8
--- /dev/null
+++ b/app/DoctrineMigrations/Version20161128131503.php
@@ -0,0 +1,61 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Removed locked, credentials_expire_at and expires_at.
12 */
13class 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);
59 }
60 }
61}
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
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Added index on wallabag_entry.uid
12 */
13class 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}