diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2017-01-27 09:34:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-27 09:34:32 +0100 |
commit | 6fb06904ecde15b1b07d0a2af945338b416cf0e2 (patch) | |
tree | e76f3e8142399316ec5660fab8c646b2c34b8336 /app/DoctrineMigrations/Version20160410190541.php | |
parent | 05fa529bcfde01be5d320cb532900d72cf4b0830 (diff) | |
parent | 78295b99dd1721c613f1ce52e2debbe6f6db7753 (diff) | |
download | wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.gz wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.zst wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.zip |
Merge pull request #2416 from wallabag/2.2
wallabag 2.2.0
Diffstat (limited to 'app/DoctrineMigrations/Version20160410190541.php')
-rw-r--r-- | app/DoctrineMigrations/Version20160410190541.php | 25 |
1 files changed, 15 insertions, 10 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 | } |