aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-07-10 21:32:25 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-05-29 13:50:59 +0200
commitb7fa51ae7dd5fef2d9459100c88479413ddd3fb3 (patch)
tree0395f1ada65ba54578ab13b8c2398592b65bd6a1 /app/DoctrineMigrations
parente9579d6de9ea99522e5905e8bb827e858c8da1fc (diff)
downloadwallabag-b7fa51ae7dd5fef2d9459100c88479413ddd3fb3.tar.gz
wallabag-b7fa51ae7dd5fef2d9459100c88479413ddd3fb3.tar.zst
wallabag-b7fa51ae7dd5fef2d9459100c88479413ddd3fb3.zip
Added given_url in entry table
- Added index on entry table for given_url field - Fix tests: The previous `bit.ly` url redirected to doc.wallabag but that url doesn't exist in the fixtures. I used our own internal "redirector" to create a redirect to an url which exist in the fixtures. Also, updating current migration to use the new `WallabagMigration`.
Diffstat (limited to 'app/DoctrineMigrations')
-rw-r--r--app/DoctrineMigrations/Version20170710125843.php38
-rw-r--r--app/DoctrineMigrations/Version20171218135243.php48
2 files changed, 86 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20170710125843.php b/app/DoctrineMigrations/Version20170710125843.php
new file mode 100644
index 00000000..2cf8647a
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170710125843.php
@@ -0,0 +1,38 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Schema\Schema;
6use Wallabag\CoreBundle\Doctrine\WallabagMigration;
7
8/**
9 * Added `given_url` field in entry table.
10 */
11class Version20170710125843 extends WallabagMigration
12{
13 /**
14 * @param Schema $schema
15 */
16 public function up(Schema $schema)
17 {
18 $entryTable = $schema->getTable($this->getTable('entry'));
19
20 $this->skipIf($entryTable->hasColumn('given_url'), 'It seems that you already played this migration.');
21
22 $entryTable->addColumn('given_url', 'text', [
23 'notnull' => false,
24 ]);
25 }
26
27 /**
28 * @param Schema $schema
29 */
30 public function down(Schema $schema)
31 {
32 $entryTable = $schema->getTable($this->getTable('entry'));
33
34 $this->skipIf(!$entryTable->hasColumn('given_url'), 'It seems that you already played this migration.');
35
36 $entryTable->dropColumn('given_url');
37 }
38}
diff --git a/app/DoctrineMigrations/Version20171218135243.php b/app/DoctrineMigrations/Version20171218135243.php
new file mode 100644
index 00000000..3060c920
--- /dev/null
+++ b/app/DoctrineMigrations/Version20171218135243.php
@@ -0,0 +1,48 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Schema\Schema;
6use Wallabag\CoreBundle\Doctrine\WallabagMigration;
7
8/**
9 * Added indexes on wallabag_entry.url and wallabag_entry.given_url and wallabag_entry.user_id.
10 */
11class Version20171218135243 extends WallabagMigration
12{
13 private $indexGivenUrl = 'IDX_entry_given_url';
14
15 /**
16 * @param Schema $schema
17 */
18 public function up(Schema $schema)
19 {
20 $entryTable = $schema->getTable($this->getTable('entry'));
21 $this->skipIf($entryTable->hasIndex($this->indexGivenUrl), 'It seems that you already played this migration.');
22
23 switch ($this->connection->getDatabasePlatform()->getName()) {
24 case 'sqlite':
25 $sql = 'CREATE UNIQUE INDEX ' . $this->indexGivenUrl . ' ON ' . $this->getTable('entry') . ' (url, given_url, user_id);';
26 break;
27 case 'mysql':
28 $sql = 'CREATE UNIQUE INDEX ' . $this->indexGivenUrl . ' ON ' . $this->getTable('entry') . ' (url (255), given_url (255), user_id);';
29 break;
30 case 'postgresql':
31 $sql = 'CREATE UNIQUE INDEX ' . $this->indexGivenUrl . ' ON ' . $this->getTable('entry') . ' (url, given_url, user_id);';
32 break;
33 }
34
35 $this->addSql($sql);
36 }
37
38 /**
39 * @param Schema $schema
40 */
41 public function down(Schema $schema)
42 {
43 $entryTable = $schema->getTable($this->getTable('entry'));
44 $this->skipIf(false === $entryTable->hasIndex($this->indexGivenUrl), 'It seems that you already played this migration.');
45
46 $entryTable->dropIndex($this->indexGivenUrl);
47 }
48}