aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20170511211659.php
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2019-07-01 20:35:09 +0200
committerGitHub <noreply@github.com>2019-07-01 20:35:09 +0200
commitbbc67a5589e8927f3c0a72b3596f362a036db3e9 (patch)
treefb796549cf1f8f3df2b538df2ab49ed44e712bec /app/DoctrineMigrations/Version20170511211659.php
parent5c29ae4cf69c63033a23c1f5f3d76aa9131d32dc (diff)
parentb8fa1b13a65f448ce6a8ac0745acc123f4af627e (diff)
downloadwallabag-bbc67a5589e8927f3c0a72b3596f362a036db3e9.tar.gz
wallabag-bbc67a5589e8927f3c0a72b3596f362a036db3e9.tar.zst
wallabag-bbc67a5589e8927f3c0a72b3596f362a036db3e9.zip
Merge pull request #4039 from wallabag/fix/missing-wallabag-prefix-migration
Fix hardcoded `wallabag_` prefix in migrations
Diffstat (limited to 'app/DoctrineMigrations/Version20170511211659.php')
-rw-r--r--app/DoctrineMigrations/Version20170511211659.php26
1 files changed, 14 insertions, 12 deletions
diff --git a/app/DoctrineMigrations/Version20170511211659.php b/app/DoctrineMigrations/Version20170511211659.php
index 00ce7b1f..d0752baf 100644
--- a/app/DoctrineMigrations/Version20170511211659.php
+++ b/app/DoctrineMigrations/Version20170511211659.php
@@ -13,19 +13,21 @@ class Version20170511211659 extends WallabagMigration
13{ 13{
14 public function up(Schema $schema) 14 public function up(Schema $schema)
15 { 15 {
16 $tableName = $this->getTable('annotation');
17
18 switch ($this->connection->getDatabasePlatform()->getName()) { 16 switch ($this->connection->getDatabasePlatform()->getName()) {
19 case 'sqlite': 17 case 'sqlite':
18 $annotationTableName = $this->getTable('annotation', true);
19 $userTableName = $this->getTable('user', true);
20 $entryTableName = $this->getTable('entry', true);
21
20 $this->addSql(<<<EOD 22 $this->addSql(<<<EOD
21CREATE TEMPORARY TABLE __temp__wallabag_annotation AS 23CREATE TEMPORARY TABLE __temp__wallabag_annotation AS
22 SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges 24 SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges
23 FROM ${tableName} 25 FROM ${annotationTableName}
24EOD 26EOD
25 ); 27 );
26 $this->addSql('DROP TABLE ' . $tableName); 28 $this->addSql('DROP TABLE ' . $annotationTableName);
27 $this->addSql(<<<EOD 29 $this->addSql(<<<EOD
28CREATE TABLE ${tableName} 30CREATE TABLE ${annotationTableName}
29( 31(
30 id INTEGER PRIMARY KEY NOT NULL, 32 id INTEGER PRIMARY KEY NOT NULL,
31 user_id INTEGER DEFAULT NULL, 33 user_id INTEGER DEFAULT NULL,
@@ -35,16 +37,16 @@ CREATE TABLE ${tableName}
35 updated_at DATETIME NOT NULL, 37 updated_at DATETIME NOT NULL,
36 quote CLOB NOT NULL, 38 quote CLOB NOT NULL,
37 ranges CLOB NOT NULL, 39 ranges CLOB NOT NULL,
38 CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES wallabag_user (id), 40 CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES ${userTableName} (id),
39 CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES wallabag_entry (id) ON DELETE CASCADE 41 CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES ${entryTableName} (id) ON DELETE CASCADE
40); 42);
41CREATE INDEX IDX_A7AED006A76ED395 ON wallabag_annotation (user_id); 43CREATE INDEX IDX_A7AED006A76ED395 ON ${annotationTableName} (user_id);
42CREATE INDEX IDX_A7AED006BA364942 ON wallabag_annotation (entry_id); 44CREATE INDEX IDX_A7AED006BA364942 ON ${annotationTableName} (entry_id);
43EOD 45EOD
44 ); 46 );
45 47
46 $this->addSql(<<<EOD 48 $this->addSql(<<<EOD
47INSERT INTO ${tableName} (id, user_id, entry_id, text, created_at, updated_at, quote, ranges) 49INSERT INTO ${annotationTableName} (id, user_id, entry_id, text, created_at, updated_at, quote, ranges)
48SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges 50SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges
49FROM __temp__wallabag_annotation; 51FROM __temp__wallabag_annotation;
50EOD 52EOD
@@ -52,10 +54,10 @@ EOD
52 $this->addSql('DROP TABLE __temp__wallabag_annotation'); 54 $this->addSql('DROP TABLE __temp__wallabag_annotation');
53 break; 55 break;
54 case 'mysql': 56 case 'mysql':
55 $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote TEXT NOT NULL'); 57 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' MODIFY quote TEXT NOT NULL');
56 break; 58 break;
57 case 'postgresql': 59 case 'postgresql':
58 $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE TEXT'); 60 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' ALTER COLUMN quote TYPE TEXT');
59 break; 61 break;
60 } 62 }
61 } 63 }