diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-10-24 11:57:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-24 11:57:51 +0200 |
commit | 9313ea9d440e3f93a6bb2d8c0fb6717364cd27f5 (patch) | |
tree | 659842576e853a536c67e7c74139a73853b6caf2 /app/DoctrineMigrations | |
parent | a1c18418288a9521c980c96fd5defffc757a81c6 (diff) | |
parent | f623516e107c8146f87d815f033cecb5d812466a (diff) | |
download | wallabag-9313ea9d440e3f93a6bb2d8c0fb6717364cd27f5.tar.gz wallabag-9313ea9d440e3f93a6bb2d8c0fb6717364cd27f5.tar.zst wallabag-9313ea9d440e3f93a6bb2d8c0fb6717364cd27f5.zip |
Merge pull request #2401 from wallabag/reset-account
Reset account
Diffstat (limited to 'app/DoctrineMigrations')
-rw-r--r-- | app/DoctrineMigrations/Version20160410190541.php | 12 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20160812120952.php | 15 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20160911214952.php | 4 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20160916201049.php | 6 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20161001072726.php | 63 | ||||
-rw-r--r-- | app/DoctrineMigrations/Version20161022134138.php | 77 |
6 files changed, 164 insertions, 13 deletions
diff --git a/app/DoctrineMigrations/Version20160410190541.php b/app/DoctrineMigrations/Version20160410190541.php index 4014857b..c41b0465 100644 --- a/app/DoctrineMigrations/Version20160410190541.php +++ b/app/DoctrineMigrations/Version20160410190541.php | |||
@@ -29,8 +29,12 @@ class Version20160410190541 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('entry').'` ADD `uuid` LONGTEXT DEFAULT NULL'); | 32 | if ($this->connection->getDatabasePlatform()->getName() == 'postgresql') { |
33 | $this->addSql("INSERT INTO `".$this->getTable('craue_config_setting')."` (`name`, `value`, `section`) VALUES ('share_public', '1', '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 | $this->addSql("INSERT INTO ".$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_public', '1', 'entry')"); | ||
34 | } | 38 | } |
35 | 39 | ||
36 | /** | 40 | /** |
@@ -40,7 +44,7 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI | |||
40 | { | 44 | { |
41 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.'); | 45 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.'); |
42 | 46 | ||
43 | $this->addSql('ALTER TABLE `'.$this->getTable('entry').'` DROP `uuid`'); | 47 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' DROP uuid'); |
44 | $this->addSql("DELETE FROM `".$this->getTable('craue_config_setting')."` WHERE `name` = 'share_public'"); | 48 | $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'share_public'"); |
45 | } | 49 | } |
46 | } | 50 | } |
diff --git a/app/DoctrineMigrations/Version20160812120952.php b/app/DoctrineMigrations/Version20160812120952.php index a8d3bcf2..39423e2f 100644 --- a/app/DoctrineMigrations/Version20160812120952.php +++ b/app/DoctrineMigrations/Version20160812120952.php | |||
@@ -29,10 +29,17 @@ class Version20160812120952 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() == 'sqlite') { | 32 | switch ($this->connection->getDatabasePlatform()->getName()) { |
33 | $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext DEFAULT NULL'); | 33 | case 'sqlite': |
34 | } else { | 34 | $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext DEFAULT NULL'); |
35 | $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext COLLATE \'utf8_unicode_ci\' DEFAULT NULL'); | 35 | break; |
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'); | ||
36 | } | 43 | } |
37 | } | 44 | } |
38 | 45 | ||
diff --git a/app/DoctrineMigrations/Version20160911214952.php b/app/DoctrineMigrations/Version20160911214952.php index 35809cec..3f988ccf 100644 --- a/app/DoctrineMigrations/Version20160911214952.php +++ b/app/DoctrineMigrations/Version20160911214952.php | |||
@@ -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 | /** |
diff --git a/app/DoctrineMigrations/Version20160916201049.php b/app/DoctrineMigrations/Version20160916201049.php index 202901e6..fc4e700a 100644 --- a/app/DoctrineMigrations/Version20160916201049.php +++ b/app/DoctrineMigrations/Version20160916201049.php | |||
@@ -30,7 +30,7 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI | |||
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 | $this->addSql('ALTER TABLE '.$this->getTable('config').' ADD pocket_consumer_key VARCHAR(255) DEFAULT NULL'); |
33 | $this->addSql("DELETE FROM `".$this->getTable('craue_config_setting')."` WHERE `name` = 'pocket_consumer_key';"); | 33 | $this->addSql("DELETE FROM ".$this->getTable('craue_config_setting')." WHERE name = 'pocket_consumer_key';"); |
34 | } | 34 | } |
35 | 35 | ||
36 | /** | 36 | /** |
@@ -40,7 +40,7 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI | |||
40 | { | 40 | { |
41 | $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); | 41 | $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); |
42 | 42 | ||
43 | $this->addSql('ALTER TABLE `'.$this->getTable('config').'` DROP pocket_consumer_key'); | 43 | $this->addSql('ALTER TABLE '.$this->getTable('config').' DROP pocket_consumer_key'); |
44 | $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 | } | 45 | } |
46 | } | 46 | } |
diff --git a/app/DoctrineMigrations/Version20161001072726.php b/app/DoctrineMigrations/Version20161001072726.php new file mode 100644 index 00000000..237db932 --- /dev/null +++ b/app/DoctrineMigrations/Version20161001072726.php | |||
@@ -0,0 +1,63 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | class 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 | $query = $this->connection->query("SELECT CONSTRAINT_NAME FROM information_schema.key_column_usage WHERE TABLE_NAME = '".$this->getTable('entry_tag')."' AND CONSTRAINT_NAME LIKE 'FK_%' AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'"); | ||
36 | $query->execute(); | ||
37 | |||
38 | foreach ($query->fetchAll() as $fk) { | ||
39 | $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']); | ||
40 | } | ||
41 | |||
42 | $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'); | ||
43 | $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'); | ||
44 | |||
45 | // remove entry FK from annotation | ||
46 | $query = $this->connection->query("SELECT CONSTRAINT_NAME FROM information_schema.key_column_usage WHERE TABLE_NAME = '".$this->getTable('annotation')."' AND CONSTRAINT_NAME LIKE 'FK_%' and COLUMN_NAME = 'entry_id' AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'"); | ||
47 | $query->execute(); | ||
48 | |||
49 | foreach ($query->fetchAll() as $fk) { | ||
50 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']); | ||
51 | } | ||
52 | |||
53 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' ADD CONSTRAINT FK_annotation_entry FOREIGN KEY (entry_id) REFERENCES '.$this->getTable('entry').' (id) ON DELETE CASCADE'); | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * @param Schema $schema | ||
58 | */ | ||
59 | public function down(Schema $schema) | ||
60 | { | ||
61 | throw new SkipMigrationException('Too complex ...'); | ||
62 | } | ||
63 | } | ||
diff --git a/app/DoctrineMigrations/Version20161022134138.php b/app/DoctrineMigrations/Version20161022134138.php new file mode 100644 index 00000000..5cce55a5 --- /dev/null +++ b/app/DoctrineMigrations/Version20161022134138.php | |||
@@ -0,0 +1,77 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | class 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->container->getParameter('database_name').' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;'); | ||
35 | |||
36 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
37 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
38 | $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
39 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
40 | |||
41 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
42 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
43 | |||
44 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
45 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
46 | |||
47 | $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
48 | |||
49 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); | ||
50 | } | ||
51 | |||
52 | /** | ||
53 | * @param Schema $schema | ||
54 | */ | ||
55 | public function down(Schema $schema) | ||
56 | { | ||
57 | $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); | ||
58 | |||
59 | $this->addSql('ALTER DATABASE '.$this->container->getParameter('database_name').' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;'); | ||
60 | |||
61 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
62 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
63 | $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
64 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
65 | |||
66 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
67 | $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
68 | |||
69 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
70 | $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
71 | |||
72 | $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
73 | |||
74 | $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); | ||
75 | |||
76 | } | ||
77 | } | ||