diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2019-06-05 11:38:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-05 11:38:00 +0200 |
commit | 16e1c07553d276f6a4df8fb0f2d1aa25026d73be (patch) | |
tree | 30771618e781968dbbc79fa7113db266017a35ae /app/DoctrineMigrations | |
parent | 8671da5eadc93204f2742bb6b2b5b8fc1eddf131 (diff) | |
parent | d8809f70ea3a2f88635827b37af23b2fc2a93db6 (diff) | |
download | wallabag-16e1c07553d276f6a4df8fb0f2d1aa25026d73be.tar.gz wallabag-16e1c07553d276f6a4df8fb0f2d1aa25026d73be.tar.zst wallabag-16e1c07553d276f6a4df8fb0f2d1aa25026d73be.zip |
Merge pull request #3271 from wallabag/store-resolved-url
Add `given_url` in Entry table to check if a redirected url has already added
Diffstat (limited to 'app/DoctrineMigrations')
-rw-r--r-- | app/DoctrineMigrations/Version20190601125843.php | 54 |
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 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Schema\Schema; | ||
6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; | ||
7 | |||
8 | /** | ||
9 | * Added `given_url` & `hashed_given_url` field in entry table. | ||
10 | */ | ||
11 | class 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 | } | ||