aboutsummaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/DoctrineMigrations/Version20160410190541.php21
-rw-r--r--app/DoctrineMigrations/Version20160812120952.php23
-rw-r--r--app/DoctrineMigrations/Version20160911214952.php8
-rw-r--r--app/DoctrineMigrations/Version20160916201049.php17
-rw-r--r--app/DoctrineMigrations/Version20161001072726.php2
-rw-r--r--app/DoctrineMigrations/Version20161022134138.php3
-rw-r--r--app/DoctrineMigrations/Version20161024212538.php17
-rw-r--r--app/DoctrineMigrations/Version20161031132655.php8
-rw-r--r--app/DoctrineMigrations/Version20161104073720.php23
-rw-r--r--app/DoctrineMigrations/Version20161106113822.php15
-rw-r--r--app/DoctrineMigrations/Version20161117071626.php10
-rw-r--r--app/DoctrineMigrations/Version20161118134328.php18
-rw-r--r--app/DoctrineMigrations/Version20161122144743.php8
-rw-r--r--app/DoctrineMigrations/Version20161122203647.php17
14 files changed, 101 insertions, 89 deletions
diff --git a/app/DoctrineMigrations/Version20160410190541.php b/app/DoctrineMigrations/Version20160410190541.php
index f034b0e4..0cdec008 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,14 @@ 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('uuid'), 'It seems that you already played this migration.');
35
36 $entryTable->addColumn('uuid', 'guid', [
37 'notnull' => false,
38 ]);
39 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_public', '1', 'entry')");
39 } 40 }
40 41
41 /** 42 /**
@@ -43,9 +44,9 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
43 */ 44 */
44 public function down(Schema $schema) 45 public function down(Schema $schema)
45 { 46 {
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.'); 47 $entryTable = $schema->getTable($this->getTable('entry'));
48 $entryTable->dropColumn('uuid');
47 49
48 $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" DROP uuid'); 50 $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 } 51 }
51} 52}
diff --git a/app/DoctrineMigrations/Version20160812120952.php b/app/DoctrineMigrations/Version20160812120952.php
index 39423e2f..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,18 +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
37 case 'mysql':
38 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext COLLATE \'utf8_unicode_ci\' DEFAULT NULL');
39 break;
40
41 case 'postgresql':
42 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name text DEFAULT NULL');
43 }
44 } 36 }
45 37
46 /** 38 /**
@@ -48,8 +40,7 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
48 */ 40 */
49 public function down(Schema $schema) 41 public function down(Schema $schema)
50 { 42 {
51 $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'));
52 44 $clientsTable->dropColumn('name');
53 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' DROP COLUMN name');
54 } 45 }
55} 46}
diff --git a/app/DoctrineMigrations/Version20160911214952.php b/app/DoctrineMigrations/Version20160911214952.php
index f14f7bc6..963821ae 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,8 @@ 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 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_redis', 0, 'import')");
33 $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting').'" (name, value, section) VALUES (\'import_with_rabbitmq\', \'0\', \'import\')'); 33 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')");
34 } 34 }
35 35
36 /** 36 /**
@@ -38,5 +38,7 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
38 */ 38 */
39 public function down(Schema $schema) 39 public function down(Schema $schema)
40 { 40 {
41 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis';");
42 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq';");
41 } 43 }
42} 44}
diff --git a/app/DoctrineMigrations/Version20160916201049.php b/app/DoctrineMigrations/Version20160916201049.php
index 0d2edf9e..9390755e 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');
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
index 237db932..5ab88555 100644
--- a/app/DoctrineMigrations/Version20161001072726.php
+++ b/app/DoctrineMigrations/Version20161001072726.php
@@ -21,7 +21,7 @@ class Version20161001072726 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 /**
diff --git a/app/DoctrineMigrations/Version20161022134138.php b/app/DoctrineMigrations/Version20161022134138.php
index 5cce55a5..b3d02b40 100644
--- a/app/DoctrineMigrations/Version20161022134138.php
+++ b/app/DoctrineMigrations/Version20161022134138.php
@@ -21,7 +21,7 @@ class Version20161022134138 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 /**
@@ -72,6 +72,5 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
72 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 72 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
73 73
74 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 74 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
75
76 } 75 }
77} 76}
diff --git a/app/DoctrineMigrations/Version20161024212538.php b/app/DoctrineMigrations/Version20161024212538.php
index f8e927e4..75ff86f1 100644
--- a/app/DoctrineMigrations/Version20161024212538.php
+++ b/app/DoctrineMigrations/Version20161024212538.php
@@ -21,7 +21,7 @@ class Version20161024212538 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,10 +29,18 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
29 */ 29 */
30 public function up(Schema $schema) 30 public function up(Schema $schema)
31 { 31 {
32 $this->skipIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); 32 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
33 33
34 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD user_id INT(11) DEFAULT NULL'); 34 $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
35 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD CONSTRAINT FK_clients_user_clients FOREIGN KEY (user_id) REFERENCES '.$this->getTable('user').' (id) ON DELETE CASCADE'); 35
36 $clientsTable->addColumn('user_id', 'integer');
37
38 $clientsTable->addForeignKeyConstraint(
39 $this->getTable('user'),
40 ['user_id'],
41 ['id'],
42 ['onDelete' => 'CASCADE']
43 );
36 } 44 }
37 45
38 /** 46 /**
@@ -40,6 +48,5 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
40 */ 48 */
41 public function down(Schema $schema) 49 public function down(Schema $schema)
42 { 50 {
43
44 } 51 }
45} 52}
diff --git a/app/DoctrineMigrations/Version20161031132655.php b/app/DoctrineMigrations/Version20161031132655.php
index c7364428..39b85ea9 100644
--- a/app/DoctrineMigrations/Version20161031132655.php
+++ b/app/DoctrineMigrations/Version20161031132655.php
@@ -21,7 +21,7 @@ class Version20161031132655 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,7 +29,7 @@ class Version20161031132655 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 ('download_images_enabled', 0, 'misc')"); 32 $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
33 } 33 }
34 34
35 /** 35 /**
@@ -37,8 +37,6 @@ class Version20161031132655 extends AbstractMigration implements ContainerAwareI
37 */ 37 */
38 public function down(Schema $schema) 38 public function down(Schema $schema)
39 { 39 {
40 $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); 40 $this->addSql('DELETE FROM "'.$this->getTable('craue_config_setting')."\" WHERE name = 'download_images_enabled';");
41
42 $this->addSql("DELETE FROM \"".$this->getTable('craue_config_setting')."\" WHERE name = 'download_images_enabled';");
43 } 41 }
44} 42}
diff --git a/app/DoctrineMigrations/Version20161104073720.php b/app/DoctrineMigrations/Version20161104073720.php
index 16503b4b..4721426a 100644
--- a/app/DoctrineMigrations/Version20161104073720.php
+++ b/app/DoctrineMigrations/Version20161104073720.php
@@ -14,6 +14,8 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI
14 */ 14 */
15 private $container; 15 private $container;
16 16
17 private $indexName = 'IDX_entry_created_at';
18
17 public function setContainer(ContainerInterface $container = null) 19 public function setContainer(ContainerInterface $container = null)
18 { 20 {
19 $this->container = $container; 21 $this->container = $container;
@@ -21,7 +23,7 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI
21 23
22 private function getTable($tableName) 24 private function getTable($tableName)
23 { 25 {
24 return $this->container->getParameter('database_table_prefix') . $tableName; 26 return $this->container->getParameter('database_table_prefix').$tableName;
25 } 27 }
26 28
27 /** 29 /**
@@ -29,18 +31,10 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI
29 */ 31 */
30 public function up(Schema $schema) 32 public function up(Schema $schema)
31 { 33 {
32 switch ($this->connection->getDatabasePlatform()->getName()) { 34 $entryTable = $schema->getTable($this->getTable('entry'));
33 case 'sqlite': 35 $this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
34 $this->addSql('CREATE INDEX `created_at` ON `'.$this->getTable('entry').'` (`created_at` DESC)'); 36
35 break; 37 $entryTable->addIndex(['created_at'], $this->indexName);
36
37 case 'mysql':
38 $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD INDEX created_at (created_at);');
39 break;
40
41 case 'postgresql':
42 $this->addSql('CREATE INDEX created_at ON '.$this->getTable('entry').' (created_at DESC)');
43 }
44 } 38 }
45 39
46 /** 40 /**
@@ -48,6 +42,9 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI
48 */ 42 */
49 public function down(Schema $schema) 43 public function down(Schema $schema)
50 { 44 {
45 $entryTable = $schema->getTable($this->getTable('entry'));
46 $this->skipIf(false === $entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
51 47
48 $entryTable->dropIndex($this->indexName);
52 } 49 }
53} 50}
diff --git a/app/DoctrineMigrations/Version20161106113822.php b/app/DoctrineMigrations/Version20161106113822.php
index edca54f5..5032a8f0 100644
--- a/app/DoctrineMigrations/Version20161106113822.php
+++ b/app/DoctrineMigrations/Version20161106113822.php
@@ -21,7 +21,7 @@ class Version20161106113822 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,7 +29,13 @@ class Version20161106113822 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 action_mark_as_read INT DEFAULT 0'); 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 ]);
33 } 39 }
34 40
35 /** 41 /**
@@ -37,8 +43,7 @@ class Version20161106113822 extends AbstractMigration implements ContainerAwareI
37 */ 43 */
38 public function down(Schema $schema) 44 public function down(Schema $schema)
39 { 45 {
40 $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.'); 46 $configTable = $schema->getTable($this->getTable('config'));
41 47 $userTable->dropColumn('action_mark_as_read');
42 $this->addSql('ALTER TABLE '.$this->getTable('config').' DROP action_mark_as_read');
43 } 48 }
44} 49}
diff --git a/app/DoctrineMigrations/Version20161117071626.php b/app/DoctrineMigrations/Version20161117071626.php
index 9ae55b5f..33f5707e 100644
--- a/app/DoctrineMigrations/Version20161117071626.php
+++ b/app/DoctrineMigrations/Version20161117071626.php
@@ -21,7 +21,7 @@ class Version20161117071626 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,8 @@ class Version20161117071626 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 ('share_unmark', 0, 'entry')"); 32 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')");
33 $this->addSql("INSERT INTO ".$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')"); 33 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
34 } 34 }
35 35
36 /** 36 /**
@@ -38,7 +38,7 @@ class Version20161117071626 extends AbstractMigration implements ContainerAwareI
38 */ 38 */
39 public function down(Schema $schema) 39 public function down(Schema $schema)
40 { 40 {
41 $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'share_unmark';"); 41 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark';");
42 $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'unmark_url';"); 42 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url';");
43 } 43 }
44} 44}
diff --git a/app/DoctrineMigrations/Version20161118134328.php b/app/DoctrineMigrations/Version20161118134328.php
index 390e89ce..f168cb53 100644
--- a/app/DoctrineMigrations/Version20161118134328.php
+++ b/app/DoctrineMigrations/Version20161118134328.php
@@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface; 8use Symfony\Component\DependencyInjection\ContainerInterface;
9 9
10/** 10/**
11 * Add http_status in `entry_table` 11 * Add http_status in `entry_table`.
12 */ 12 */
13class Version20161118134328 extends AbstractMigration implements ContainerAwareInterface 13class Version20161118134328 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -24,7 +24,7 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
24 24
25 private function getTable($tableName) 25 private function getTable($tableName)
26 { 26 {
27 return $this->container->getParameter('database_table_prefix') . $tableName; 27 return $this->container->getParameter('database_table_prefix').$tableName;
28 } 28 }
29 29
30 /** 30 /**
@@ -32,7 +32,14 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
32 */ 32 */
33 public function up(Schema $schema) 33 public function up(Schema $schema)
34 { 34 {
35 $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD http_status VARCHAR(3) DEFAULT NULL'); 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 ]);
36 } 43 }
37 44
38 /** 45 /**
@@ -40,8 +47,7 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
40 */ 47 */
41 public function down(Schema $schema) 48 public function down(Schema $schema)
42 { 49 {
43 $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.'); 50 $userTable = $schema->getTable($this->getTable('entry'));
44 51 $userTable->dropColumn('http_status');
45 $this->addSql('ALTER TABLE '.$this->getTable('entry').' DROP http_status');
46 } 52 }
47} 53}
diff --git a/app/DoctrineMigrations/Version20161122144743.php b/app/DoctrineMigrations/Version20161122144743.php
index ec80c48e..536b8339 100644
--- a/app/DoctrineMigrations/Version20161122144743.php
+++ b/app/DoctrineMigrations/Version20161122144743.php
@@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface; 8use Symfony\Component\DependencyInjection\ContainerInterface;
9 9
10/** 10/**
11 * Add the restricted_access internal setting for articles with paywall 11 * Add the restricted_access internal setting for articles with paywall.
12 */ 12 */
13class Version20161122144743 extends AbstractMigration implements ContainerAwareInterface 13class Version20161122144743 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -24,7 +24,7 @@ class Version20161122144743 extends AbstractMigration implements ContainerAwareI
24 24
25 private function getTable($tableName) 25 private function getTable($tableName)
26 { 26 {
27 return $this->container->getParameter('database_table_prefix') . $tableName; 27 return $this->container->getParameter('database_table_prefix').$tableName;
28 } 28 }
29 29
30 /** 30 /**
@@ -32,7 +32,7 @@ class Version20161122144743 extends AbstractMigration implements ContainerAwareI
32 */ 32 */
33 public function up(Schema $schema) 33 public function up(Schema $schema)
34 { 34 {
35 $this->addSql("INSERT INTO ".$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')"); 35 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')");
36 } 36 }
37 37
38 /** 38 /**
@@ -40,6 +40,6 @@ class Version20161122144743 extends AbstractMigration implements ContainerAwareI
40 */ 40 */
41 public function down(Schema $schema) 41 public function down(Schema $schema)
42 { 42 {
43 $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'restricted_access';"); 43 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'restricted_access';");
44 } 44 }
45} 45}
diff --git a/app/DoctrineMigrations/Version20161122203647.php b/app/DoctrineMigrations/Version20161122203647.php
index ea2703b6..94197193 100644
--- a/app/DoctrineMigrations/Version20161122203647.php
+++ b/app/DoctrineMigrations/Version20161122203647.php
@@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface; 8use Symfony\Component\DependencyInjection\ContainerInterface;
9 9
10/** 10/**
11 * Methods and properties removed from `FOS\UserBundle\Model\User` 11 * Methods and properties removed from `FOS\UserBundle\Model\User`.
12 * 12 *
13 * - `$expired` 13 * - `$expired`
14 * - `$credentialsExpired` 14 * - `$credentialsExpired`
@@ -32,7 +32,7 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
32 32
33 private function getTable($tableName) 33 private function getTable($tableName)
34 { 34 {
35 return $this->container->getParameter('database_table_prefix') . $tableName; 35 return $this->container->getParameter('database_table_prefix').$tableName;
36 } 36 }
37 37
38 /** 38 /**
@@ -40,10 +40,12 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
40 */ 40 */
41 public function up(Schema $schema) 41 public function up(Schema $schema)
42 { 42 {
43 $this->abortIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'This up migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.'); 43 $userTable = $schema->getTable($this->getTable('user'));
44 44
45 $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP expired'); 45 $this->skipIf(false === $userTable->hasColumn('expired') || false === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
46 $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP credentials_expired'); 46
47 $userTable->dropColumn('expired');
48 $userTable->dropColumn('credentials_expired');
47 } 49 }
48 50
49 /** 51 /**
@@ -51,7 +53,8 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
51 */ 53 */
52 public function down(Schema $schema) 54 public function down(Schema $schema)
53 { 55 {
54 $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD expired tinyint(1) NULL DEFAULT 0'); 56 $userTable = $schema->getTable($this->getTable('user'));
55 $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD credentials_expired tinyint(1) NULL DEFAULT 0'); 57 $userTable->addColumn('expired', 'smallint');
58 $userTable->addColumn('credentials_expired', 'smallint');
56 } 59 }
57} 60}