aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations
diff options
context:
space:
mode:
Diffstat (limited to 'app/DoctrineMigrations')
-rw-r--r--app/DoctrineMigrations/Version20160410190541.php18
-rw-r--r--app/DoctrineMigrations/Version20160812120952.php12
-rw-r--r--app/DoctrineMigrations/Version20160911214952.php24
-rw-r--r--app/DoctrineMigrations/Version20160916201049.php16
-rw-r--r--app/DoctrineMigrations/Version20161001072726.php44
-rw-r--r--app/DoctrineMigrations/Version20161022134138.php66
-rw-r--r--app/DoctrineMigrations/Version20161024212538.php14
-rw-r--r--app/DoctrineMigrations/Version20161031132655.php18
-rw-r--r--app/DoctrineMigrations/Version20161104073720.php12
-rw-r--r--app/DoctrineMigrations/Version20161106113822.php12
-rw-r--r--app/DoctrineMigrations/Version20161117071626.php24
-rw-r--r--app/DoctrineMigrations/Version20161118134328.php10
-rw-r--r--app/DoctrineMigrations/Version20161122144743.php16
-rw-r--r--app/DoctrineMigrations/Version20161122203647.php10
-rw-r--r--app/DoctrineMigrations/Version20161128084725.php10
-rw-r--r--app/DoctrineMigrations/Version20161128131503.php10
-rw-r--r--app/DoctrineMigrations/Version20161214094402.php28
-rw-r--r--app/DoctrineMigrations/Version20161214094403.php12
-rw-r--r--app/DoctrineMigrations/Version20170127093841.php12
-rw-r--r--app/DoctrineMigrations/Version20170327194233.php54
-rw-r--r--app/DoctrineMigrations/Version20170405182620.php65
-rw-r--r--app/DoctrineMigrations/Version20170407200919.php51
-rw-r--r--app/DoctrineMigrations/Version20170420134133.php52
-rw-r--r--app/DoctrineMigrations/Version20170501115751.php61
-rw-r--r--app/DoctrineMigrations/Version20170510082609.php60
-rw-r--r--app/DoctrineMigrations/Version20170511115400.php55
-rw-r--r--app/DoctrineMigrations/Version20170511211659.php96
-rw-r--r--app/DoctrineMigrations/Version20170602075214.php52
-rw-r--r--app/DoctrineMigrations/Version20170606155640.php53
-rw-r--r--app/DoctrineMigrations/Version20170719231144.php103
-rw-r--r--app/DoctrineMigrations/Version20170824113337.php63
-rw-r--r--app/DoctrineMigrations/Version20171008195606.php64
32 files changed, 1012 insertions, 185 deletions
diff --git a/app/DoctrineMigrations/Version20160410190541.php b/app/DoctrineMigrations/Version20160410190541.php
index 6294d842..55c12ce1 100644
--- a/app/DoctrineMigrations/Version20160410190541.php
+++ b/app/DoctrineMigrations/Version20160410190541.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 * Added foreign keys for account resetting 11 * Added foreign keys for account resetting.
12 */ 12 */
13class Version20160410190541 extends AbstractMigration implements ContainerAwareInterface 13class Version20160410190541 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -22,11 +22,6 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -44,10 +39,10 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
44 $sharePublic = $this->container 39 $sharePublic = $this->container
45 ->get('doctrine.orm.default_entity_manager') 40 ->get('doctrine.orm.default_entity_manager')
46 ->getConnection() 41 ->getConnection()
47 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'"); 42 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_public'");
48 43
49 if (false === $sharePublic) { 44 if (false === $sharePublic) {
50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_public', '1', 'entry')"); 45 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_public', '1', 'entry')");
51 } 46 }
52 } 47 }
53 48
@@ -59,6 +54,11 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
59 $entryTable = $schema->getTable($this->getTable('entry')); 54 $entryTable = $schema->getTable($this->getTable('entry'));
60 $entryTable->dropColumn('uid'); 55 $entryTable->dropColumn('uid');
61 56
62 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'"); 57 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_public'");
58 }
59
60 private function getTable($tableName)
61 {
62 return $this->container->getParameter('database_table_prefix') . $tableName;
63 } 63 }
64} 64}
diff --git a/app/DoctrineMigrations/Version20160812120952.php b/app/DoctrineMigrations/Version20160812120952.php
index bd6e8d63..677f30c3 100644
--- a/app/DoctrineMigrations/Version20160812120952.php
+++ b/app/DoctrineMigrations/Version20160812120952.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 * Added name field on wallabag_oauth2_clients 11 * Added name field on wallabag_oauth2_clients.
12 */ 12 */
13class Version20160812120952 extends AbstractMigration implements ContainerAwareInterface 13class Version20160812120952 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -22,11 +22,6 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -46,4 +41,9 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
46 $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); 41 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
47 $clientsTable->dropColumn('name'); 42 $clientsTable->dropColumn('name');
48 } 43 }
44
45 private function getTable($tableName)
46 {
47 return $this->container->getParameter('database_table_prefix') . $tableName;
48 }
49} 49}
diff --git a/app/DoctrineMigrations/Version20160911214952.php b/app/DoctrineMigrations/Version20160911214952.php
index edef81ed..08cc8a03 100644
--- a/app/DoctrineMigrations/Version20160911214952.php
+++ b/app/DoctrineMigrations/Version20160911214952.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 * Added settings for RabbitMQ and Redis imports 11 * Added settings for RabbitMQ and Redis imports.
12 */ 12 */
13class Version20160911214952 extends AbstractMigration implements ContainerAwareInterface 13class Version20160911214952 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -22,11 +22,6 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -35,19 +30,19 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
35 $redis = $this->container 30 $redis = $this->container
36 ->get('doctrine.orm.default_entity_manager') 31 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection() 32 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis'"); 33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_redis'");
39 34
40 if (false === $redis) { 35 if (false === $redis) {
41 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_redis', 0, 'import')"); 36 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('import_with_redis', 0, 'import')");
42 } 37 }
43 38
44 $rabbitmq = $this->container 39 $rabbitmq = $this->container
45 ->get('doctrine.orm.default_entity_manager') 40 ->get('doctrine.orm.default_entity_manager')
46 ->getConnection() 41 ->getConnection()
47 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq'"); 42 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_rabbitmq'");
48 43
49 if (false === $rabbitmq) { 44 if (false === $rabbitmq) {
50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')"); 45 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')");
51 } 46 }
52 47
53 $this->skipIf(false !== $rabbitmq && false !== $redis, 'It seems that you already played this migration.'); 48 $this->skipIf(false !== $rabbitmq && false !== $redis, 'It seems that you already played this migration.');
@@ -58,7 +53,12 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
58 */ 53 */
59 public function down(Schema $schema) 54 public function down(Schema $schema)
60 { 55 {
61 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis';"); 56 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_redis';");
62 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq';"); 57 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_rabbitmq';");
58 }
59
60 private function getTable($tableName)
61 {
62 return $this->container->getParameter('database_table_prefix') . $tableName;
63 } 63 }
64} 64}
diff --git a/app/DoctrineMigrations/Version20160916201049.php b/app/DoctrineMigrations/Version20160916201049.php
index 9f8e77e7..83503bc4 100644
--- a/app/DoctrineMigrations/Version20160916201049.php
+++ b/app/DoctrineMigrations/Version20160916201049.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 * Added pocket_consumer_key field on wallabag_config 11 * Added pocket_consumer_key field on wallabag_config.
12 */ 12 */
13class Version20160916201049 extends AbstractMigration implements ContainerAwareInterface 13class Version20160916201049 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -22,11 +22,6 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -37,7 +32,7 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
37 $this->skipIf($configTable->hasColumn('pocket_consumer_key'), 'It seems that you already played this migration.'); 32 $this->skipIf($configTable->hasColumn('pocket_consumer_key'), 'It seems that you already played this migration.');
38 33
39 $configTable->addColumn('pocket_consumer_key', 'string', ['notnull' => false]); 34 $configTable->addColumn('pocket_consumer_key', 'string', ['notnull' => false]);
40 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'pocket_consumer_key';"); 35 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'pocket_consumer_key';");
41 } 36 }
42 37
43 /** 38 /**
@@ -47,6 +42,11 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
47 { 42 {
48 $configTable = $schema->getTable($this->getTable('config')); 43 $configTable = $schema->getTable($this->getTable('config'));
49 $configTable->dropColumn('pocket_consumer_key'); 44 $configTable->dropColumn('pocket_consumer_key');
50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')"); 45 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')");
46 }
47
48 private function getTable($tableName)
49 {
50 return $this->container->getParameter('database_table_prefix') . $tableName;
51 } 51 }
52} 52}
diff --git a/app/DoctrineMigrations/Version20161001072726.php b/app/DoctrineMigrations/Version20161001072726.php
index f247c236..f9d088a3 100644
--- a/app/DoctrineMigrations/Version20161001072726.php
+++ b/app/DoctrineMigrations/Version20161001072726.php
@@ -3,13 +3,13 @@
3namespace Application\Migrations; 3namespace Application\Migrations;
4 4
5use Doctrine\DBAL\Migrations\AbstractMigration; 5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Migrations\SkipMigrationException;
6use Doctrine\DBAL\Schema\Schema; 7use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface; 8use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface; 9use Symfony\Component\DependencyInjection\ContainerInterface;
9use Doctrine\DBAL\Migrations\SkipMigrationException;
10 10
11/** 11/**
12 * Added pocket_consumer_key field on wallabag_config 12 * Added pocket_consumer_key field on wallabag_config.
13 */ 13 */
14class Version20161001072726 extends AbstractMigration implements ContainerAwareInterface 14class Version20161001072726 extends AbstractMigration implements ContainerAwareInterface
15{ 15{
@@ -23,17 +23,12 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
23 $this->container = $container; 23 $this->container = $container;
24 } 24 }
25 25
26 private function getTable($tableName)
27 {
28 return $this->container->getParameter('database_table_prefix').$tableName;
29 }
30
31 /** 26 /**
32 * @param Schema $schema 27 * @param Schema $schema
33 */ 28 */
34 public function up(Schema $schema) 29 public function up(Schema $schema)
35 { 30 {
36 $this->skipIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); 31 $this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
37 32
38 // remove all FK from entry_tag 33 // remove all FK from entry_tag
39 switch ($this->connection->getDatabasePlatform()->getName()) { 34 switch ($this->connection->getDatabasePlatform()->getName()) {
@@ -41,16 +36,15 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
41 $query = $this->connection->query(" 36 $query = $this->connection->query("
42 SELECT CONSTRAINT_NAME 37 SELECT CONSTRAINT_NAME
43 FROM information_schema.key_column_usage 38 FROM information_schema.key_column_usage
44 WHERE TABLE_NAME = '".$this->getTable('entry_tag')."' AND CONSTRAINT_NAME LIKE 'FK_%' 39 WHERE TABLE_NAME = '" . $this->getTable('entry_tag') . "' AND CONSTRAINT_NAME LIKE 'FK_%'
45 AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'" 40 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
46 ); 41 );
47 $query->execute(); 42 $query->execute();
48 43
49 foreach ($query->fetchAll() as $fk) { 44 foreach ($query->fetchAll() as $fk) {
50 $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']); 45 $this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' DROP FOREIGN KEY ' . $fk['CONSTRAINT_NAME']);
51 } 46 }
52 break; 47 break;
53
54 case 'postgresql': 48 case 'postgresql':
55 // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk 49 // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk
56 $query = $this->connection->query(" 50 $query = $this->connection->query("
@@ -60,19 +54,19 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
60 FROM pg_constraint c 54 FROM pg_constraint c
61 JOIN pg_namespace n ON n.oid = c.connamespace 55 JOIN pg_namespace n ON n.oid = c.connamespace
62 WHERE contype = 'f' 56 WHERE contype = 'f'
63 AND conrelid::regclass::text = '".$this->getTable('entry_tag')."' 57 AND conrelid::regclass::text = '" . $this->getTable('entry_tag') . "'
64 AND n.nspname = 'public';" 58 AND n.nspname = 'public';"
65 ); 59 );
66 $query->execute(); 60 $query->execute();
67 61
68 foreach ($query->fetchAll() as $fk) { 62 foreach ($query->fetchAll() as $fk) {
69 $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP CONSTRAINT '.$fk['conname']); 63 $this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' DROP CONSTRAINT ' . $fk['conname']);
70 } 64 }
71 break; 65 break;
72 } 66 }
73 67
74 $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'); 68 $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');
75 $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'); 69 $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');
76 70
77 // remove entry FK from annotation 71 // remove entry FK from annotation
78 72
@@ -81,18 +75,17 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
81 $query = $this->connection->query(" 75 $query = $this->connection->query("
82 SELECT CONSTRAINT_NAME 76 SELECT CONSTRAINT_NAME
83 FROM information_schema.key_column_usage 77 FROM information_schema.key_column_usage
84 WHERE TABLE_NAME = '".$this->getTable('annotation')."' 78 WHERE TABLE_NAME = '" . $this->getTable('annotation') . "'
85 AND CONSTRAINT_NAME LIKE 'FK_%' 79 AND CONSTRAINT_NAME LIKE 'FK_%'
86 AND COLUMN_NAME = 'entry_id' 80 AND COLUMN_NAME = 'entry_id'
87 AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'" 81 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
88 ); 82 );
89 $query->execute(); 83 $query->execute();
90 84
91 foreach ($query->fetchAll() as $fk) { 85 foreach ($query->fetchAll() as $fk) {
92 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']); 86 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' DROP FOREIGN KEY ' . $fk['CONSTRAINT_NAME']);
93 } 87 }
94 break; 88 break;
95
96 case 'postgresql': 89 case 'postgresql':
97 // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk 90 // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk
98 $query = $this->connection->query(" 91 $query = $this->connection->query("
@@ -102,19 +95,19 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
102 FROM pg_constraint c 95 FROM pg_constraint c
103 JOIN pg_namespace n ON n.oid = c.connamespace 96 JOIN pg_namespace n ON n.oid = c.connamespace
104 WHERE contype = 'f' 97 WHERE contype = 'f'
105 AND conrelid::regclass::text = '".$this->getTable('annotation')."' 98 AND conrelid::regclass::text = '" . $this->getTable('annotation') . "'
106 AND n.nspname = 'public' 99 AND n.nspname = 'public'
107 AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';" 100 AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';"
108 ); 101 );
109 $query->execute(); 102 $query->execute();
110 103
111 foreach ($query->fetchAll() as $fk) { 104 foreach ($query->fetchAll() as $fk) {
112 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP CONSTRAINT '.$fk['conname']); 105 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' DROP CONSTRAINT ' . $fk['conname']);
113 } 106 }
114 break; 107 break;
115 } 108 }
116 109
117 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' ADD CONSTRAINT FK_annotation_entry FOREIGN KEY (entry_id) REFERENCES '.$this->getTable('entry').' (id) ON DELETE CASCADE'); 110 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' ADD CONSTRAINT FK_annotation_entry FOREIGN KEY (entry_id) REFERENCES ' . $this->getTable('entry') . ' (id) ON DELETE CASCADE');
118 } 111 }
119 112
120 /** 113 /**
@@ -124,4 +117,9 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
124 { 117 {
125 throw new SkipMigrationException('Too complex ...'); 118 throw new SkipMigrationException('Too complex ...');
126 } 119 }
120
121 private function getTable($tableName)
122 {
123 return $this->container->getParameter('database_table_prefix') . $tableName;
124 }
127} 125}
diff --git a/app/DoctrineMigrations/Version20161022134138.php b/app/DoctrineMigrations/Version20161022134138.php
index c71166a0..c84f8fbb 100644
--- a/app/DoctrineMigrations/Version20161022134138.php
+++ b/app/DoctrineMigrations/Version20161022134138.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 * Converted database to utf8mb4 encoding (for MySQL only) 11 * Converted database to utf8mb4 encoding (for MySQL only).
12 */ 12 */
13class Version20161022134138 extends AbstractMigration implements ContainerAwareInterface 13class Version20161022134138 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -22,40 +22,35 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
33 public function up(Schema $schema) 28 public function up(Schema $schema)
34 { 29 {
35 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); 30 $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
36 31
37 $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;'); 32 $this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
38 33
39 // convert field length for utf8mb4 34 // convert field length for utf8mb4
40 // http://stackoverflow.com/a/31474509/569101 35 // http://stackoverflow.com/a/31474509/569101
41 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;'); 36 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;');
42 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE salt salt VARCHAR(180) NOT NULL;'); 37 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE salt salt VARCHAR(180) NOT NULL;');
43 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE password password VARCHAR(180) NOT NULL;'); 38 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE password password VARCHAR(180) NOT NULL;');
44 39
45 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 40 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
46 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 41 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
47 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 42 $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
48 $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 43 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
49 44
50 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 45 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `text` `text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
51 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 46 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `quote` `quote` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
52 47
53 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 48 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `title` `title` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
54 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 49 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `content` `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
55 50
56 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 51 $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
57 52
58 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 53 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE `name` `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
59 } 54 }
60 55
61 /** 56 /**
@@ -63,23 +58,28 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
63 */ 58 */
64 public function down(Schema $schema) 59 public function down(Schema $schema)
65 { 60 {
66 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); 61 $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
67 62
68 $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;'); 63 $this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
69 64
70 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 65 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
71 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 66 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
72 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 67 $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
73 $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 68 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
74 69
75 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 70 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `text` `text` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
76 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 71 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `quote` `quote` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
77 72
78 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 73 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `title` `title` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
79 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 74 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `content` `content` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
80 75
81 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 76 $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
82 77
83 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 78 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
79 }
80
81 private function getTable($tableName)
82 {
83 return $this->container->getParameter('database_table_prefix') . $tableName;
84 } 84 }
85} 85}
diff --git a/app/DoctrineMigrations/Version20161024212538.php b/app/DoctrineMigrations/Version20161024212538.php
index ecb872d1..698819be 100644
--- a/app/DoctrineMigrations/Version20161024212538.php
+++ b/app/DoctrineMigrations/Version20161024212538.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 * Added user_id column on oauth2_clients to prevent users to delete API clients from other users 11 * Added user_id column on oauth2_clients to prevent users to delete API clients from other users.
12 */ 12 */
13class Version20161024212538 extends AbstractMigration implements ContainerAwareInterface 13class Version20161024212538 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -24,11 +24,6 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
24 $this->container = $container; 24 $this->container = $container;
25 } 25 }
26 26
27 private function getTable($tableName)
28 {
29 return $this->container->getParameter('database_table_prefix').$tableName;
30 }
31
32 /** 27 /**
33 * @param Schema $schema 28 * @param Schema $schema
34 */ 29 */
@@ -60,8 +55,13 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
60 55
61 $clientsTable->dropColumn('user_id', 'integer'); 56 $clientsTable->dropColumn('user_id', 'integer');
62 57
63 if ($this->connection->getDatabasePlatform()->getName() != 'sqlite') { 58 if ('sqlite' !== $this->connection->getDatabasePlatform()->getName()) {
64 $clientsTable->removeForeignKey($this->constraintName); 59 $clientsTable->removeForeignKey($this->constraintName);
65 } 60 }
66 } 61 }
62
63 private function getTable($tableName)
64 {
65 return $this->container->getParameter('database_table_prefix') . $tableName;
66 }
67} 67}
diff --git a/app/DoctrineMigrations/Version20161031132655.php b/app/DoctrineMigrations/Version20161031132655.php
index 83b97ca9..0deebdf9 100644
--- a/app/DoctrineMigrations/Version20161031132655.php
+++ b/app/DoctrineMigrations/Version20161031132655.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 * Added the internal setting to enable/disable downloading pictures 11 * Added the internal setting to enable/disable downloading pictures.
12 */ 12 */
13class Version20161031132655 extends AbstractMigration implements ContainerAwareInterface 13class Version20161031132655 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -22,11 +22,6 @@ class Version20161031132655 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -35,11 +30,11 @@ class Version20161031132655 extends AbstractMigration implements ContainerAwareI
35 $images = $this->container 30 $images = $this->container
36 ->get('doctrine.orm.default_entity_manager') 31 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection() 32 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled'"); 33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_images_enabled'");
39 34
40 $this->skipIf(false !== $images, 'It seems that you already played this migration.'); 35 $this->skipIf(false !== $images, 'It seems that you already played this migration.');
41 36
42 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('download_images_enabled', 0, 'misc')"); 37 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
43 } 38 }
44 39
45 /** 40 /**
@@ -47,6 +42,11 @@ class Version20161031132655 extends AbstractMigration implements ContainerAwareI
47 */ 42 */
48 public function down(Schema $schema) 43 public function down(Schema $schema)
49 { 44 {
50 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled';"); 45 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_images_enabled';");
46 }
47
48 private function getTable($tableName)
49 {
50 return $this->container->getParameter('database_table_prefix') . $tableName;
51 } 51 }
52} 52}
diff --git a/app/DoctrineMigrations/Version20161104073720.php b/app/DoctrineMigrations/Version20161104073720.php
index fb8f5fa1..f59ad7ba 100644
--- a/app/DoctrineMigrations/Version20161104073720.php
+++ b/app/DoctrineMigrations/Version20161104073720.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 * Added created_at index on entry table 11 * Added created_at index on entry table.
12 */ 12 */
13class Version20161104073720 extends AbstractMigration implements ContainerAwareInterface 13class Version20161104073720 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -24,11 +24,6 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI
24 $this->container = $container; 24 $this->container = $container;
25 } 25 }
26 26
27 private function getTable($tableName)
28 {
29 return $this->container->getParameter('database_table_prefix').$tableName;
30 }
31
32 /** 27 /**
33 * @param Schema $schema 28 * @param Schema $schema
34 */ 29 */
@@ -50,4 +45,9 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI
50 45
51 $entryTable->dropIndex($this->indexName); 46 $entryTable->dropIndex($this->indexName);
52 } 47 }
48
49 private function getTable($tableName)
50 {
51 return $this->container->getParameter('database_table_prefix') . $tableName;
52 }
53} 53}
diff --git a/app/DoctrineMigrations/Version20161106113822.php b/app/DoctrineMigrations/Version20161106113822.php
index de3702a4..1d5a865b 100644
--- a/app/DoctrineMigrations/Version20161106113822.php
+++ b/app/DoctrineMigrations/Version20161106113822.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 * Added action_mark_as_read field on config table 11 * Added action_mark_as_read field on config table.
12 */ 12 */
13class Version20161106113822 extends AbstractMigration implements ContainerAwareInterface 13class Version20161106113822 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -22,11 +22,6 @@ class Version20161106113822 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -53,4 +48,9 @@ class Version20161106113822 extends AbstractMigration implements ContainerAwareI
53 48
54 $configTable->dropColumn('action_mark_as_read'); 49 $configTable->dropColumn('action_mark_as_read');
55 } 50 }
51
52 private function getTable($tableName)
53 {
54 return $this->container->getParameter('database_table_prefix') . $tableName;
55 }
56} 56}
diff --git a/app/DoctrineMigrations/Version20161117071626.php b/app/DoctrineMigrations/Version20161117071626.php
index 8daa2142..0b34caab 100644
--- a/app/DoctrineMigrations/Version20161117071626.php
+++ b/app/DoctrineMigrations/Version20161117071626.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 * Added the internal setting to share articles to unmark.it 11 * Added the internal setting to share articles to unmark.it.
12 */ 12 */
13class Version20161117071626 extends AbstractMigration implements ContainerAwareInterface 13class Version20161117071626 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -22,11 +22,6 @@ class Version20161117071626 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -35,19 +30,19 @@ class Version20161117071626 extends AbstractMigration implements ContainerAwareI
35 $share = $this->container 30 $share = $this->container
36 ->get('doctrine.orm.default_entity_manager') 31 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection() 32 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark'"); 33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_unmark'");
39 34
40 if (false === $share) { 35 if (false === $share) {
41 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')"); 36 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_unmark', 0, 'entry')");
42 } 37 }
43 38
44 $unmark = $this->container 39 $unmark = $this->container
45 ->get('doctrine.orm.default_entity_manager') 40 ->get('doctrine.orm.default_entity_manager')
46 ->getConnection() 41 ->getConnection()
47 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url'"); 42 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'unmark_url'");
48 43
49 if (false === $unmark) { 44 if (false === $unmark) {
50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')"); 45 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
51 } 46 }
52 47
53 $this->skipIf(false !== $share && false !== $unmark, 'It seems that you already played this migration.'); 48 $this->skipIf(false !== $share && false !== $unmark, 'It seems that you already played this migration.');
@@ -58,7 +53,12 @@ class Version20161117071626 extends AbstractMigration implements ContainerAwareI
58 */ 53 */
59 public function down(Schema $schema) 54 public function down(Schema $schema)
60 { 55 {
61 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark';"); 56 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_unmark';");
62 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url';"); 57 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'unmark_url';");
58 }
59
60 private function getTable($tableName)
61 {
62 return $this->container->getParameter('database_table_prefix') . $tableName;
63 } 63 }
64} 64}
diff --git a/app/DoctrineMigrations/Version20161118134328.php b/app/DoctrineMigrations/Version20161118134328.php
index 7b2eeb7b..dab0ff5b 100644
--- a/app/DoctrineMigrations/Version20161118134328.php
+++ b/app/DoctrineMigrations/Version20161118134328.php
@@ -22,11 +22,6 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -53,4 +48,9 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
53 48
54 $entryTable->dropColumn('http_status'); 49 $entryTable->dropColumn('http_status');
55 } 50 }
51
52 private function getTable($tableName)
53 {
54 return $this->container->getParameter('database_table_prefix') . $tableName;
55 }
56} 56}
diff --git a/app/DoctrineMigrations/Version20161122144743.php b/app/DoctrineMigrations/Version20161122144743.php
index 388a0e4b..15052ad7 100644
--- a/app/DoctrineMigrations/Version20161122144743.php
+++ b/app/DoctrineMigrations/Version20161122144743.php
@@ -22,11 +22,6 @@ class Version20161122144743 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -35,11 +30,11 @@ class Version20161122144743 extends AbstractMigration implements ContainerAwareI
35 $access = $this->container 30 $access = $this->container
36 ->get('doctrine.orm.default_entity_manager') 31 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection() 32 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'restricted_access'"); 33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'restricted_access'");
39 34
40 $this->skipIf(false !== $access, 'It seems that you already played this migration.'); 35 $this->skipIf(false !== $access, 'It seems that you already played this migration.');
41 36
42 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')"); 37 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('restricted_access', 0, 'entry')");
43 } 38 }
44 39
45 /** 40 /**
@@ -47,6 +42,11 @@ class Version20161122144743 extends AbstractMigration implements ContainerAwareI
47 */ 42 */
48 public function down(Schema $schema) 43 public function down(Schema $schema)
49 { 44 {
50 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'restricted_access';"); 45 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'restricted_access';");
46 }
47
48 private function getTable($tableName)
49 {
50 return $this->container->getParameter('database_table_prefix') . $tableName;
51 } 51 }
52} 52}
diff --git a/app/DoctrineMigrations/Version20161122203647.php b/app/DoctrineMigrations/Version20161122203647.php
index 9b17d6ef..ef08bd59 100644
--- a/app/DoctrineMigrations/Version20161122203647.php
+++ b/app/DoctrineMigrations/Version20161122203647.php
@@ -30,11 +30,6 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
30 $this->container = $container; 30 $this->container = $container;
31 } 31 }
32 32
33 private function getTable($tableName)
34 {
35 return $this->container->getParameter('database_table_prefix').$tableName;
36 }
37
38 /** 33 /**
39 * @param Schema $schema 34 * @param Schema $schema
40 */ 35 */
@@ -60,4 +55,9 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
60 $userTable->addColumn('expired', 'smallint', ['notnull' => false]); 55 $userTable->addColumn('expired', 'smallint', ['notnull' => false]);
61 $userTable->addColumn('credentials_expired', 'smallint', ['notnull' => false]); 56 $userTable->addColumn('credentials_expired', 'smallint', ['notnull' => false]);
62 } 57 }
58
59 private function getTable($tableName)
60 {
61 return $this->container->getParameter('database_table_prefix') . $tableName;
62 }
63} 63}
diff --git a/app/DoctrineMigrations/Version20161128084725.php b/app/DoctrineMigrations/Version20161128084725.php
index ea370076..497a9f21 100644
--- a/app/DoctrineMigrations/Version20161128084725.php
+++ b/app/DoctrineMigrations/Version20161128084725.php
@@ -22,11 +22,6 @@ class Version20161128084725 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -46,4 +41,9 @@ class Version20161128084725 extends AbstractMigration implements ContainerAwareI
46 $configTable = $schema->getTable($this->getTable('config')); 41 $configTable = $schema->getTable($this->getTable('config'));
47 $configTable->dropColumn('list_mode'); 42 $configTable->dropColumn('list_mode');
48 } 43 }
44
45 private function getTable($tableName)
46 {
47 return $this->container->getParameter('database_table_prefix') . $tableName;
48 }
49} 49}
diff --git a/app/DoctrineMigrations/Version20161128131503.php b/app/DoctrineMigrations/Version20161128131503.php
index b71aa38b..9d92983a 100644
--- a/app/DoctrineMigrations/Version20161128131503.php
+++ b/app/DoctrineMigrations/Version20161128131503.php
@@ -28,11 +28,6 @@ class Version20161128131503 extends AbstractMigration implements ContainerAwareI
28 $this->container = $container; 28 $this->container = $container;
29 } 29 }
30 30
31 private function getTable($tableName)
32 {
33 return $this->container->getParameter('database_table_prefix').$tableName;
34 }
35
36 /** 31 /**
37 * @param Schema $schema 32 * @param Schema $schema
38 */ 33 */
@@ -58,4 +53,9 @@ class Version20161128131503 extends AbstractMigration implements ContainerAwareI
58 $userTable->addColumn($field, $type, ['notnull' => false]); 53 $userTable->addColumn($field, $type, ['notnull' => false]);
59 } 54 }
60 } 55 }
56
57 private function getTable($tableName)
58 {
59 return $this->container->getParameter('database_table_prefix') . $tableName;
60 }
61} 61}
diff --git a/app/DoctrineMigrations/Version20161214094402.php b/app/DoctrineMigrations/Version20161214094402.php
index db125f76..07090b2f 100644
--- a/app/DoctrineMigrations/Version20161214094402.php
+++ b/app/DoctrineMigrations/Version20161214094402.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 * Renamed uuid to uid in entry table 11 * Renamed uuid to uid in entry table.
12 */ 12 */
13class Version20161214094402 extends AbstractMigration implements ContainerAwareInterface 13class Version20161214094402 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -22,11 +22,6 @@ class Version20161214094402 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -38,17 +33,17 @@ class Version20161214094402 extends AbstractMigration implements ContainerAwareI
38 33
39 switch ($this->connection->getDatabasePlatform()->getName()) { 34 switch ($this->connection->getDatabasePlatform()->getName()) {
40 case 'sqlite': 35 case 'sqlite':
41 $this->addSql('CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM '.$this->getTable('entry')); 36 $this->addSql('CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM ' . $this->getTable('entry'));
42 $this->addSql('DROP TABLE '.$this->getTable('entry')); 37 $this->addSql('DROP TABLE ' . $this->getTable('entry'));
43 $this->addSql('CREATE TABLE '.$this->getTable('entry').' (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid CLOB DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT "0", PRIMARY KEY(id));'); 38 $this->addSql('CREATE TABLE ' . $this->getTable('entry') . ' (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid CLOB DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT "0", PRIMARY KEY(id));');
44 $this->addSql('INSERT INTO '.$this->getTable('entry').' (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public) SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM __temp__wallabag_entry;'); 39 $this->addSql('INSERT INTO ' . $this->getTable('entry') . ' (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public) SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM __temp__wallabag_entry;');
45 $this->addSql('DROP TABLE __temp__wallabag_entry'); 40 $this->addSql('DROP TABLE __temp__wallabag_entry');
46 break; 41 break;
47 case 'mysql': 42 case 'mysql':
48 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE uuid uid VARCHAR(23)'); 43 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE uuid uid VARCHAR(23)');
49 break; 44 break;
50 case 'postgresql': 45 case 'postgresql':
51 $this->addSql('ALTER TABLE '.$this->getTable('entry').' RENAME uuid TO uid'); 46 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' RENAME uuid TO uid');
52 } 47 }
53 } 48 }
54 49
@@ -66,10 +61,15 @@ class Version20161214094402 extends AbstractMigration implements ContainerAwareI
66 throw new SkipMigrationException('Too complex ...'); 61 throw new SkipMigrationException('Too complex ...');
67 break; 62 break;
68 case 'mysql': 63 case 'mysql':
69 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE uid uuid VARCHAR(23)'); 64 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE uid uuid VARCHAR(23)');
70 break; 65 break;
71 case 'postgresql': 66 case 'postgresql':
72 $this->addSql('ALTER TABLE '.$this->getTable('entry').' RENAME uid TO uuid'); 67 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' RENAME uid TO uuid');
73 } 68 }
74 } 69 }
70
71 private function getTable($tableName)
72 {
73 return $this->container->getParameter('database_table_prefix') . $tableName;
74 }
75} 75}
diff --git a/app/DoctrineMigrations/Version20161214094403.php b/app/DoctrineMigrations/Version20161214094403.php
index 5948b5fa..6b5640e5 100644
--- a/app/DoctrineMigrations/Version20161214094403.php
+++ b/app/DoctrineMigrations/Version20161214094403.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 * Added index on wallabag_entry.uid 11 * Added index on wallabag_entry.uid.
12 */ 12 */
13class Version20161214094403 extends AbstractMigration implements ContainerAwareInterface 13class Version20161214094403 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -24,11 +24,6 @@ class Version20161214094403 extends AbstractMigration implements ContainerAwareI
24 $this->container = $container; 24 $this->container = $container;
25 } 25 }
26 26
27 private function getTable($tableName)
28 {
29 return $this->container->getParameter('database_table_prefix').$tableName;
30 }
31
32 /** 27 /**
33 * @param Schema $schema 28 * @param Schema $schema
34 */ 29 */
@@ -50,4 +45,9 @@ class Version20161214094403 extends AbstractMigration implements ContainerAwareI
50 45
51 $entryTable->dropIndex($this->indexName); 46 $entryTable->dropIndex($this->indexName);
52 } 47 }
48
49 private function getTable($tableName)
50 {
51 return $this->container->getParameter('database_table_prefix') . $tableName;
52 }
53} 53}
diff --git a/app/DoctrineMigrations/Version20170127093841.php b/app/DoctrineMigrations/Version20170127093841.php
index 20c79479..fc78a246 100644
--- a/app/DoctrineMigrations/Version20170127093841.php
+++ b/app/DoctrineMigrations/Version20170127093841.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 * Added indexes on wallabag_entry.is_starred and wallabag_entry.is_archived 11 * Added indexes on wallabag_entry.is_starred and wallabag_entry.is_archived.
12 */ 12 */
13class Version20170127093841 extends AbstractMigration implements ContainerAwareInterface 13class Version20170127093841 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -25,11 +25,6 @@ class Version20170127093841 extends AbstractMigration implements ContainerAwareI
25 $this->container = $container; 25 $this->container = $container;
26 } 26 }
27 27
28 private function getTable($tableName)
29 {
30 return $this->container->getParameter('database_table_prefix').$tableName;
31 }
32
33 /** 28 /**
34 * @param Schema $schema 29 * @param Schema $schema
35 */ 30 */
@@ -53,4 +48,9 @@ class Version20170127093841 extends AbstractMigration implements ContainerAwareI
53 $entryTable->dropIndex($this->indexStarredName); 48 $entryTable->dropIndex($this->indexStarredName);
54 $entryTable->dropIndex($this->indexArchivedName); 49 $entryTable->dropIndex($this->indexArchivedName);
55 } 50 }
51
52 private function getTable($tableName)
53 {
54 return $this->container->getParameter('database_table_prefix') . $tableName;
55 }
56} 56}
diff --git a/app/DoctrineMigrations/Version20170327194233.php b/app/DoctrineMigrations/Version20170327194233.php
new file mode 100644
index 00000000..3e7e722d
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170327194233.php
@@ -0,0 +1,54 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add the share_scuttle internal setting.
12 */
13class Version20170327194233 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $scuttle = $this->container
31 ->get('doctrine.orm.default_entity_manager')
32 ->getConnection()
33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_scuttle'");
34
35 $this->skipIf(false !== $scuttle, 'It seems that you already played this migration.');
36
37 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_scuttle', '1', 'entry')");
38 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('scuttle_url', 'http://scuttle.org', 'entry')");
39 }
40
41 /**
42 * @param Schema $schema
43 */
44 public function down(Schema $schema)
45 {
46 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_scuttle';");
47 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'scuttle_url';");
48 }
49
50 private function getTable($tableName)
51 {
52 return $this->container->getParameter('database_table_prefix') . $tableName;
53 }
54}
diff --git a/app/DoctrineMigrations/Version20170405182620.php b/app/DoctrineMigrations/Version20170405182620.php
new file mode 100644
index 00000000..75793fcb
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170405182620.php
@@ -0,0 +1,65 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add published_at and published_by in `entry` table.
12 */
13class Version20170405182620 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $entryTable = $schema->getTable($this->getTable('entry'));
31
32 $this->skipIf($entryTable->hasColumn('published_at'), 'It seems that you already played this migration.');
33
34 $entryTable->addColumn('published_at', 'datetime', [
35 'notnull' => false,
36 ]);
37
38 $this->skipIf($entryTable->hasColumn('published_by'), 'It seems that you already played this migration.');
39
40 $entryTable->addColumn('published_by', 'text', [
41 'notnull' => false,
42 ]);
43 }
44
45 /**
46 * @param Schema $schema
47 */
48 public function down(Schema $schema)
49 {
50 $entryTable = $schema->getTable($this->getTable('entry'));
51
52 $this->skipIf(!$entryTable->hasColumn('published_at'), 'It seems that you already played this migration.');
53
54 $entryTable->dropColumn('published_at');
55
56 $this->skipIf(!$entryTable->hasColumn('published_by'), 'It seems that you already played this migration.');
57
58 $entryTable->dropColumn('published_by');
59 }
60
61 private function getTable($tableName)
62 {
63 return $this->container->getParameter('database_table_prefix') . $tableName;
64 }
65}
diff --git a/app/DoctrineMigrations/Version20170407200919.php b/app/DoctrineMigrations/Version20170407200919.php
new file mode 100644
index 00000000..8a11ffe3
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170407200919.php
@@ -0,0 +1,51 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Remove isPublic in Entry Table.
12 */
13class Version20170407200919 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $entryTable = $schema->getTable($this->getTable('entry'));
31 $this->skipIf(!$entryTable->hasColumn('is_public'), 'It seems that you already played this migration.');
32
33 $entryTable->dropColumn('is_public');
34 }
35
36 /**
37 * @param Schema $schema
38 */
39 public function down(Schema $schema)
40 {
41 $entryTable = $schema->getTable($this->getTable('entry'));
42 $this->skipIf($entryTable->hasColumn('is_public'), 'It seems that you already played this migration.');
43
44 $entryTable->addColumn('is_public', 'boolean', ['notnull' => false, 'default' => 0]);
45 }
46
47 private function getTable($tableName)
48 {
49 return $this->container->getParameter('database_table_prefix') . $tableName;
50 }
51}
diff --git a/app/DoctrineMigrations/Version20170420134133.php b/app/DoctrineMigrations/Version20170420134133.php
new file mode 100644
index 00000000..e1947a49
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170420134133.php
@@ -0,0 +1,52 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Remove download_pictures in craue_config_setting.
12 */
13class Version20170420134133 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_pictures';");
31 }
32
33 /**
34 * @param Schema $schema
35 */
36 public function down(Schema $schema)
37 {
38 $downloadPictures = $this->container
39 ->get('doctrine.orm.default_entity_manager')
40 ->getConnection()
41 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_pictures'");
42
43 $this->skipIf(false !== $downloadPictures, 'It seems that you already played this migration.');
44
45 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('download_pictures', '1', 'entry')");
46 }
47
48 private function getTable($tableName)
49 {
50 return $this->container->getParameter('database_table_prefix') . $tableName;
51 }
52}
diff --git a/app/DoctrineMigrations/Version20170501115751.php b/app/DoctrineMigrations/Version20170501115751.php
new file mode 100644
index 00000000..adf2f841
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170501115751.php
@@ -0,0 +1,61 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add site credential table to store username & password for some website (behind authentication or paywall).
12 */
13class Version20170501115751 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $this->skipIf($schema->hasTable($this->getTable('site_credential')), 'It seems that you already played this migration.');
31
32 $table = $schema->createTable($this->getTable('site_credential'));
33 $table->addColumn('id', 'integer', ['autoincrement' => true]);
34 $table->addColumn('user_id', 'integer');
35 $table->addColumn('host', 'string', ['length' => 255]);
36 $table->addColumn('username', 'text');
37 $table->addColumn('password', 'text');
38 $table->addColumn('createdAt', 'datetime');
39 $table->addIndex(['user_id'], 'idx_user');
40 $table->setPrimaryKey(['id']);
41 $table->addForeignKeyConstraint($this->getTable('user'), ['user_id'], ['id'], [], 'fk_user');
42
43 if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
44 $schema->dropSequence('site_credential_id_seq');
45 $schema->createSequence('site_credential_id_seq');
46 }
47 }
48
49 /**
50 * @param Schema $schema
51 */
52 public function down(Schema $schema)
53 {
54 $schema->dropTable($this->getTable('site_credential'));
55 }
56
57 private function getTable($tableName)
58 {
59 return $this->container->getParameter('database_table_prefix') . $tableName;
60 }
61}
diff --git a/app/DoctrineMigrations/Version20170510082609.php b/app/DoctrineMigrations/Version20170510082609.php
new file mode 100644
index 00000000..52c70168
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170510082609.php
@@ -0,0 +1,60 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Changed length for username, username_canonical, email and email_canonical fields in wallabag_user table.
12 */
13class Version20170510082609 extends AbstractMigration implements ContainerAwareInterface
14{
15 private $fields = [
16 'username',
17 'username_canonical',
18 'email',
19 'email_canonical',
20 ];
21
22 /**
23 * @var ContainerInterface
24 */
25 private $container;
26
27 public function setContainer(ContainerInterface $container = null)
28 {
29 $this->container = $container;
30 }
31
32 /**
33 * @param Schema $schema
34 */
35 public function up(Schema $schema)
36 {
37 $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
38
39 foreach ($this->fields as $field) {
40 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;');
41 }
42 }
43
44 /**
45 * @param Schema $schema
46 */
47 public function down(Schema $schema)
48 {
49 $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
50
51 foreach ($this->fields as $field) {
52 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;');
53 }
54 }
55
56 private function getTable($tableName)
57 {
58 return $this->container->getParameter('database_table_prefix') . $tableName;
59 }
60}
diff --git a/app/DoctrineMigrations/Version20170511115400.php b/app/DoctrineMigrations/Version20170511115400.php
new file mode 100644
index 00000000..cad2b637
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170511115400.php
@@ -0,0 +1,55 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Added `headers` field in entry table.
12 */
13class Version20170511115400 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $entryTable = $schema->getTable($this->getTable('entry'));
31
32 $this->skipIf($entryTable->hasColumn('headers'), 'It seems that you already played this migration.');
33
34 $entryTable->addColumn('headers', 'text', [
35 'notnull' => false,
36 ]);
37 }
38
39 /**
40 * @param Schema $schema
41 */
42 public function down(Schema $schema)
43 {
44 $entryTable = $schema->getTable($this->getTable('entry'));
45
46 $this->skipIf(!$entryTable->hasColumn('headers'), 'It seems that you already played this migration.');
47
48 $entryTable->dropColumn('headers');
49 }
50
51 private function getTable($tableName)
52 {
53 return $this->container->getParameter('database_table_prefix') . $tableName;
54 }
55}
diff --git a/app/DoctrineMigrations/Version20170511211659.php b/app/DoctrineMigrations/Version20170511211659.php
new file mode 100644
index 00000000..f004d1b3
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170511211659.php
@@ -0,0 +1,96 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Migrations\SkipMigrationException;
7use Doctrine\DBAL\Schema\Schema;
8use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9use Symfony\Component\DependencyInjection\ContainerInterface;
10
11/**
12 * Increase the length of the "quote" column of "annotation" table.
13 */
14class Version20170511211659 extends AbstractMigration implements ContainerAwareInterface
15{
16 /**
17 * @var ContainerInterface
18 */
19 private $container;
20
21 public function setContainer(ContainerInterface $container = null)
22 {
23 $this->container = $container;
24 }
25
26 public function up(Schema $schema)
27 {
28 $tableName = $this->getTable('annotation');
29
30 switch ($this->connection->getDatabasePlatform()->getName()) {
31 case 'sqlite':
32 $this->addSql(<<<EOD
33CREATE TEMPORARY TABLE __temp__wallabag_annotation AS
34 SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges
35 FROM ${tableName}
36EOD
37 );
38 $this->addSql('DROP TABLE ' . $tableName);
39 $this->addSql(<<<EOD
40CREATE TABLE ${tableName}
41(
42 id INTEGER PRIMARY KEY NOT NULL,
43 user_id INTEGER DEFAULT NULL,
44 entry_id INTEGER DEFAULT NULL,
45 text CLOB NOT NULL,
46 created_at DATETIME NOT NULL,
47 updated_at DATETIME NOT NULL,
48 quote CLOB NOT NULL,
49 ranges CLOB NOT NULL,
50 CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES wallabag_user (id),
51 CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES wallabag_entry (id) ON DELETE CASCADE
52);
53CREATE INDEX IDX_A7AED006A76ED395 ON wallabag_annotation (user_id);
54CREATE INDEX IDX_A7AED006BA364942 ON wallabag_annotation (entry_id);
55EOD
56 );
57
58 $this->addSql(<<<EOD
59INSERT INTO ${tableName} (id, user_id, entry_id, text, created_at, updated_at, quote, ranges)
60SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges
61FROM __temp__wallabag_annotation;
62EOD
63 );
64 $this->addSql('DROP TABLE __temp__wallabag_annotation');
65 break;
66 case 'mysql':
67 $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote TEXT NOT NULL');
68 break;
69 case 'postgresql':
70 $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE TEXT');
71 break;
72 }
73 }
74
75 public function down(Schema $schema)
76 {
77 $tableName = $this->getTable('annotation');
78
79 switch ($this->connection->getDatabasePlatform()->getName()) {
80 case 'sqlite':
81 throw new SkipMigrationException('Too complex ...');
82 break;
83 case 'mysql':
84 $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote VARCHAR(255) NOT NULL');
85 break;
86 case 'postgresql':
87 $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE VARCHAR(255)');
88 break;
89 }
90 }
91
92 private function getTable($tableName)
93 {
94 return $this->container->getParameter('database_table_prefix') . $tableName;
95 }
96}
diff --git a/app/DoctrineMigrations/Version20170602075214.php b/app/DoctrineMigrations/Version20170602075214.php
new file mode 100644
index 00000000..6b6f0035
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170602075214.php
@@ -0,0 +1,52 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add api_user_registration in craue_config_setting.
12 */
13class Version20170602075214 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $apiUserRegistration = $this->container
31 ->get('doctrine.orm.default_entity_manager')
32 ->getConnection()
33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'api_user_registration'");
34
35 $this->skipIf(false !== $apiUserRegistration, 'It seems that you already played this migration.');
36
37 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('api_user_registration', '0', 'api')");
38 }
39
40 /**
41 * @param Schema $schema
42 */
43 public function down(Schema $schema)
44 {
45 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'api_user_registration';");
46 }
47
48 private function getTable($tableName)
49 {
50 return $this->container->getParameter('database_table_prefix') . $tableName;
51 }
52}
diff --git a/app/DoctrineMigrations/Version20170606155640.php b/app/DoctrineMigrations/Version20170606155640.php
new file mode 100644
index 00000000..5f58fc29
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170606155640.php
@@ -0,0 +1,53 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Remove wallabag_url from craue_config_setting.
12 * It has been moved into the parameters.yml.
13 */
14class Version20170606155640 extends AbstractMigration implements ContainerAwareInterface
15{
16 /**
17 * @var ContainerInterface
18 */
19 private $container;
20
21 public function setContainer(ContainerInterface $container = null)
22 {
23 $this->container = $container;
24 }
25
26 /**
27 * @param Schema $schema
28 */
29 public function up(Schema $schema)
30 {
31 $apiUserRegistration = $this->container
32 ->get('doctrine.orm.default_entity_manager')
33 ->getConnection()
34 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'wallabag_url'");
35
36 $this->skipIf(false === $apiUserRegistration, 'It seems that you already played this migration.');
37
38 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'wallabag_url'");
39 }
40
41 /**
42 * @param Schema $schema
43 */
44 public function down(Schema $schema)
45 {
46 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('wallabag_url', 'wallabag.me', 'misc')");
47 }
48
49 private function getTable($tableName)
50 {
51 return $this->container->getParameter('database_table_prefix') . $tableName;
52 }
53}
diff --git a/app/DoctrineMigrations/Version20170719231144.php b/app/DoctrineMigrations/Version20170719231144.php
new file mode 100644
index 00000000..0c749150
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170719231144.php
@@ -0,0 +1,103 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Changed tags to lowercase.
12 */
13class Version20170719231144 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
31
32 // Find tags which need to be merged
33 $dupTags = $this->connection->query('
34 SELECT LOWER(label)
35 FROM ' . $this->getTable('tag') . '
36 GROUP BY LOWER(label)
37 HAVING COUNT(*) > 1'
38 );
39 $dupTags->execute();
40
41 foreach ($dupTags->fetchAll() as $duplicates) {
42 $label = $duplicates['LOWER(label)'];
43
44 // Retrieve all duplicate tags for a given tag
45 $tags = $this->connection->query('
46 SELECT id
47 FROM ' . $this->getTable('tag') . "
48 WHERE LOWER(label) = '" . $label . "'
49 ORDER BY id ASC"
50 );
51 $tags->execute();
52
53 $first = true;
54 $newId = null;
55 $ids = [];
56
57 foreach ($tags->fetchAll() as $tag) {
58 // Ignore the first tag as we use it as the new reference tag
59 if ($first) {
60 $first = false;
61 $newId = $tag['id'];
62 } else {
63 $ids[] = $tag['id'];
64 }
65 }
66
67 // Just in case...
68 if (count($ids) > 0) {
69 // Merge tags
70 $this->addSql('
71 UPDATE ' . $this->getTable('entry_tag') . '
72 SET tag_id = ' . $newId . '
73 WHERE tag_id IN (' . implode(',', $ids) . ')'
74 );
75
76 // Delete unused tags
77 $this->addSql('
78 DELETE FROM ' . $this->getTable('tag') . '
79 WHERE id IN (' . implode(',', $ids) . ')'
80 );
81 }
82 }
83
84 // Iterate over all tags to lowercase them
85 $this->addSql('
86 UPDATE ' . $this->getTable('tag') . '
87 SET label = LOWER(label)'
88 );
89 }
90
91 /**
92 * @param Schema $schema
93 */
94 public function down(Schema $schema)
95 {
96 throw new SkipMigrationException('Too complex ...');
97 }
98
99 private function getTable($tableName)
100 {
101 return $this->container->getParameter('database_table_prefix') . $tableName;
102 }
103}
diff --git a/app/DoctrineMigrations/Version20170824113337.php b/app/DoctrineMigrations/Version20170824113337.php
new file mode 100644
index 00000000..7393d683
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170824113337.php
@@ -0,0 +1,63 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Add starred_at column and set its value to updated_at for is_starred entries.
12 */
13class Version20170824113337 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $entryTable = $schema->getTable($this->getTable('entry'));
31
32 $this->skipIf($entryTable->hasColumn('starred_at'), 'It seems that you already played this migration.');
33
34 $entryTable->addColumn('starred_at', 'datetime', [
35 'notnull' => false,
36 ]);
37 }
38
39 public function postUp(Schema $schema)
40 {
41 $entryTable = $schema->getTable($this->getTable('entry'));
42 $this->skipIf(!$entryTable->hasColumn('starred_at'), 'Unable to add starred_at colum');
43
44 $this->connection->executeQuery('UPDATE ' . $this->getTable('entry') . ' SET starred_at = updated_at WHERE is_starred = true');
45 }
46
47 /**
48 * @param Schema $schema
49 */
50 public function down(Schema $schema)
51 {
52 $entryTable = $schema->getTable($this->getTable('entry'));
53
54 $this->skipIf(!$entryTable->hasColumn('starred_at'), 'It seems that you already played this migration.');
55
56 $entryTable->dropColumn('starred_at');
57 }
58
59 private function getTable($tableName)
60 {
61 return $this->container->getParameter('database_table_prefix') . $tableName;
62 }
63}
diff --git a/app/DoctrineMigrations/Version20171008195606.php b/app/DoctrineMigrations/Version20171008195606.php
new file mode 100644
index 00000000..c190f4ed
--- /dev/null
+++ b/app/DoctrineMigrations/Version20171008195606.php
@@ -0,0 +1,64 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Changed reading_time field to prevent null value.
12 */
13class Version20171008195606 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 /**
26 * @param Schema $schema
27 */
28 public function up(Schema $schema)
29 {
30 $this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
31
32 switch ($this->connection->getDatabasePlatform()->getName()) {
33 case 'mysql':
34 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE reading_time reading_time INT(11) NOT NULL;');
35 break;
36 case 'postgresql':
37 $this->addSql('UPDATE ' . $this->getTable('entry') . ' SET reading_time = 0 WHERE reading_time IS NULL;');
38 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' ALTER COLUMN reading_time SET NOT NULL;');
39 break;
40 }
41 }
42
43 /**
44 * @param Schema $schema
45 */
46 public function down(Schema $schema)
47 {
48 $this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
49
50 switch ($this->connection->getDatabasePlatform()->getName()) {
51 case 'mysql':
52 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE reading_time reading_time INT(11);');
53 break;
54 case 'postgresql':
55 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' ALTER COLUMN reading_time DROP NOT NULL;');
56 break;
57 }
58 }
59
60 private function getTable($tableName)
61 {
62 return $this->container->getParameter('database_table_prefix') . $tableName;
63 }
64}