aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/DoctrineMigrations/Version20161024212538.php14
-rw-r--r--app/DoctrineMigrations/Version20161031132655.php2
-rw-r--r--app/DoctrineMigrations/Version20161104073720.php14
-rw-r--r--app/DoctrineMigrations/Version20161106113822.php13
-rw-r--r--app/DoctrineMigrations/Version20161118134328.php14
-rw-r--r--app/DoctrineMigrations/Version20161122203647.php15
6 files changed, 37 insertions, 35 deletions
diff --git a/app/DoctrineMigrations/Version20161024212538.php b/app/DoctrineMigrations/Version20161024212538.php
index ced3a802..7e79cbde 100644
--- a/app/DoctrineMigrations/Version20161024212538.php
+++ b/app/DoctrineMigrations/Version20161024212538.php
@@ -29,12 +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->skipIf($schema->getTable($this->getTable('oauth2_clients'))->hasColumn('user_id'), 'It seems that you already played this migration.'); 34 $this->skipIf($clientsTable->hasColumn('user_id'), 'It seems that you already played this migration.');
35 35
36 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD user_id INT(11) DEFAULT NULL'); 36 $clientsTable->addColumn('user_id', 'integer');
37 $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'); 37
38 $clientsTable->addForeignKeyConstraint(
39 $this->getTable('user'),
40 array('user_id'),
41 array('id'),
42 array('onDelete' => 'CASCADE')
43 );
38 } 44 }
39 45
40 /** 46 /**
diff --git a/app/DoctrineMigrations/Version20161031132655.php b/app/DoctrineMigrations/Version20161031132655.php
index 80163c0b..39b85ea9 100644
--- a/app/DoctrineMigrations/Version20161031132655.php
+++ b/app/DoctrineMigrations/Version20161031132655.php
@@ -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->skipIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
41
42 $this->addSql('DELETE FROM "'.$this->getTable('craue_config_setting')."\" WHERE name = 'download_images_enabled';"); 40 $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 7a0361f8..cd2029cb 100644
--- a/app/DoctrineMigrations/Version20161104073720.php
+++ b/app/DoctrineMigrations/Version20161104073720.php
@@ -29,18 +29,8 @@ class Version20161104073720 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 $entryTable = $schema->getTable($this->getTable('entry'));
33 case 'sqlite': 33 $entryTable->addIndex(['created_at']);
34 $this->addSql('CREATE INDEX `created_at` ON `'.$this->getTable('entry').'` (`created_at` DESC)');
35 break;
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 } 34 }
45 35
46 /** 36 /**
diff --git a/app/DoctrineMigrations/Version20161106113822.php b/app/DoctrineMigrations/Version20161106113822.php
index 5e3fd562..5032a8f0 100644
--- a/app/DoctrineMigrations/Version20161106113822.php
+++ b/app/DoctrineMigrations/Version20161106113822.php
@@ -29,9 +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->skipIf($schema->getTable($this->getTable('config'))->hasColumn('action_mark_as_read'), 'It seems that you already played this migration.'); 32 $configTable = $schema->getTable($this->getTable('config'));
33 33
34 $this->addSql('ALTER TABLE '.$this->getTable('config').' ADD action_mark_as_read INT DEFAULT 0'); 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 ]);
35 } 39 }
36 40
37 /** 41 /**
@@ -39,8 +43,7 @@ class Version20161106113822 extends AbstractMigration implements ContainerAwareI
39 */ 43 */
40 public function down(Schema $schema) 44 public function down(Schema $schema)
41 { 45 {
42 $this->skipIf($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'));
43 47 $userTable->dropColumn('action_mark_as_read');
44 $this->addSql('ALTER TABLE '.$this->getTable('config').' DROP action_mark_as_read');
45 } 48 }
46} 49}
diff --git a/app/DoctrineMigrations/Version20161118134328.php b/app/DoctrineMigrations/Version20161118134328.php
index 69eae5a5..f168cb53 100644
--- a/app/DoctrineMigrations/Version20161118134328.php
+++ b/app/DoctrineMigrations/Version20161118134328.php
@@ -32,9 +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->skipIf($schema->getTable($this->getTable('entry'))->hasColumn('http_status'), 'It seems that you already played this migration.'); 35 $entryTable = $schema->getTable($this->getTable('entry'));
36 36
37 $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD http_status VARCHAR(3) DEFAULT NULL'); 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 ]);
38 } 43 }
39 44
40 /** 45 /**
@@ -42,8 +47,7 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
42 */ 47 */
43 public function down(Schema $schema) 48 public function down(Schema $schema)
44 { 49 {
45 $this->skipIf($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'));
46 51 $userTable->dropColumn('http_status');
47 $this->addSql('ALTER TABLE '.$this->getTable('entry').' DROP http_status');
48 } 52 }
49} 53}
diff --git a/app/DoctrineMigrations/Version20161122203647.php b/app/DoctrineMigrations/Version20161122203647.php
index 354a10e8..9c1557eb 100644
--- a/app/DoctrineMigrations/Version20161122203647.php
+++ b/app/DoctrineMigrations/Version20161122203647.php
@@ -40,15 +40,15 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
40 */ 40 */
41 public function up(Schema $schema) 41 public function up(Schema $schema)
42 { 42 {
43 $this->skipIf($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->skipIf(false === $schema->getTable($this->getTable('user'))->hasColumn('expired'), 'It seems that you already played this migration.'); 45 $this->skipIf(false === $userTable->hasColumn('expired'), 'It seems that you already played this migration.');
46 46
47 $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP expired'); 47 $userTable->dropColumn('expired');
48 48
49 $this->skipIf(false === $schema->getTable($this->getTable('user'))->hasColumn('credentials_expired'), 'It seems that you already played this migration.'); 49 $this->skipIf(false === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
50 50
51 $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP credentials_expired'); 51 $userTable->dropColumn('credentials_expired');
52 } 52 }
53 53
54 /** 54 /**
@@ -56,7 +56,8 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
56 */ 56 */
57 public function down(Schema $schema) 57 public function down(Schema $schema)
58 { 58 {
59 $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD expired tinyint(1) NULL DEFAULT 0'); 59 $userTable = $schema->getTable($this->getTable('user'));
60 $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD credentials_expired tinyint(1) NULL DEFAULT 0'); 60 $userTable->addColumn('expired', 'smallint');
61 $userTable->addColumn('credentials_expired', 'smallint');
61 } 62 }
62} 63}