aboutsummaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/DoctrineMigrations/Version20190601125843.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20190601125843.php b/app/DoctrineMigrations/Version20190601125843.php
new file mode 100644
index 00000000..0e97606e
--- /dev/null
+++ b/app/DoctrineMigrations/Version20190601125843.php
@@ -0,0 +1,54 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Schema\Schema;
6use Wallabag\CoreBundle\Doctrine\WallabagMigration;
7
8/**
9 * Added `given_url` & `hashed_given_url` field in entry table.
10 */
11class Version20190601125843 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 if (!$entryTable->hasColumn('given_url')) {
21 $entryTable->addColumn('given_url', 'text', [
22 'notnull' => false,
23 ]);
24 }
25
26 if (!$entryTable->hasColumn('hashed_given_url')) {
27 $entryTable->addColumn('hashed_given_url', 'text', [
28 'length' => 40,
29 'notnull' => false,
30 ]);
31 }
32
33 // 40 = length of sha1 field hashed_given_url
34 $entryTable->addIndex(['user_id', 'hashed_given_url'], 'hashed_given_url_user_id', [], ['lengths' => [null, 40]]);
35 }
36
37 /**
38 * @param Schema $schema
39 */
40 public function down(Schema $schema)
41 {
42 $entryTable = $schema->getTable($this->getTable('entry'));
43
44 if ($entryTable->hasColumn('given_url')) {
45 $entryTable->dropColumn('given_url');
46 }
47
48 if ($entryTable->hasColumn('hashed_given_url')) {
49 $entryTable->dropColumn('hashed_given_url');
50 }
51
52 $entryTable->dropIndex('hashed_given_url_user_id');
53 }
54}