aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20160410190541.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/DoctrineMigrations/Version20160410190541.php')
-rw-r--r--app/DoctrineMigrations/Version20160410190541.php19
1 files changed, 9 insertions, 10 deletions
diff --git a/app/DoctrineMigrations/Version20160410190541.php b/app/DoctrineMigrations/Version20160410190541.php
index c2360937..0cdec008 100644
--- a/app/DoctrineMigrations/Version20160410190541.php
+++ b/app/DoctrineMigrations/Version20160410190541.php
@@ -29,15 +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 $this->skipIf($schema->getTable($this->getTable('entry'))->hasColumn('uuid'), 'It seems that you already played this migration.'); 32 $entryTable = $schema->getTable($this->getTable('entry'));
33 33
34 if ($this->connection->getDatabasePlatform()->getName() == 'postgresql') { 34 $this->skipIf($entryTable->hasColumn('uuid'), 'It seems that you already played this migration.');
35 $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" ADD uuid UUID DEFAULT NULL');
36 } else {
37 $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" ADD uuid LONGTEXT DEFAULT NULL');
38 }
39 35
40 $this->addSql('INSERT INTO "'.$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('share_public', '1', 'entry')"); 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')");
41 } 40 }
42 41
43 /** 42 /**
@@ -45,9 +44,9 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
45 */ 44 */
46 public function down(Schema $schema) 45 public function down(Schema $schema)
47 { 46 {
48 $this->skipIf($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');
49 49
50 $this->addSql('ALTER TABLE "'.$this->getTable('entry').'" DROP uuid'); 50 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'");
51 $this->addSql('DELETE FROM "'.$this->getTable('craue_config_setting')."\" WHERE name = 'share_public'");
52 } 51 }
53} 52}