]> git.immae.eu Git - github/wallabag/wallabag.git/blame - app/DoctrineMigrations/Version20190401105353.php
Merge pull request #4151 from ldidry/fix-4060
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20190401105353.php
CommitLineData
9c2b2aae
JB
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Schema\Schema;
6use Wallabag\CoreBundle\Doctrine\WallabagMigration;
7
8/**
9 * Add hashed_url in entry.
10 */
11class Version20190401105353 extends WallabagMigration
12{
9c2b2aae
JB
13 public function up(Schema $schema)
14 {
15 $entryTable = $schema->getTable($this->getTable('entry'));
16
17 $this->skipIf($entryTable->hasColumn('hashed_url'), 'It seems that you already played this migration.');
18
19 $entryTable->addColumn('hashed_url', 'text', [
8a645662 20 'length' => 40,
9c2b2aae
JB
21 'notnull' => false,
22 ]);
23
5cc0646e 24 $entryTable->addIndex(['user_id', 'hashed_url'], 'hashed_url_user_id', [], ['lengths' => [null, 40]]);
9c2b2aae
JB
25 }
26
9c2b2aae
JB
27 public function down(Schema $schema)
28 {
29 $entryTable = $schema->getTable($this->getTable('entry'));
30
31 $this->skipIf(!$entryTable->hasColumn('hashed_url'), 'It seems that you already played this migration.');
32
8a645662 33 $entryTable->dropIndex('hashed_url_user_id');
9c2b2aae
JB
34 $entryTable->dropColumn('hashed_url');
35 }
36}