]> git.immae.eu Git - github/wallabag/wallabag.git/blob - app/DoctrineMigrations/Version20190601125843.php
✨ Allow custom styles system wide
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20190601125843.php
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 }