diff options
author | lizyn <zhiylin@outlook.com> | 2020-02-24 10:04:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-24 10:04:13 +0800 |
commit | b19df31d78d881a43bcf6b3215e5fc3781e8e8aa (patch) | |
tree | d0d9861694a4b5e5fbfdbeb53c255ecd15fe9328 /app/DoctrineMigrations/Version20190601125843.php | |
parent | 4d0c632c70ea50d459c3c55ddda2e0f394dd51cb (diff) | |
parent | 04d918cae0227c06a41d27fb6533dddbf30dfe71 (diff) | |
download | wallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.tar.gz wallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.tar.zst wallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.zip |
Merge pull request #1 from wallabag/master
Keep up with the master again
Diffstat (limited to 'app/DoctrineMigrations/Version20190601125843.php')
-rw-r--r-- | app/DoctrineMigrations/Version20190601125843.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20190601125843.php b/app/DoctrineMigrations/Version20190601125843.php new file mode 100644 index 00000000..cbb92edc --- /dev/null +++ b/app/DoctrineMigrations/Version20190601125843.php | |||
@@ -0,0 +1,48 @@ | |||
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 | public function up(Schema $schema) | ||
14 | { | ||
15 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
16 | |||
17 | if (!$entryTable->hasColumn('given_url')) { | ||
18 | $entryTable->addColumn('given_url', 'text', [ | ||
19 | 'notnull' => false, | ||
20 | ]); | ||
21 | } | ||
22 | |||
23 | if (!$entryTable->hasColumn('hashed_given_url')) { | ||
24 | $entryTable->addColumn('hashed_given_url', 'text', [ | ||
25 | 'length' => 40, | ||
26 | 'notnull' => false, | ||
27 | ]); | ||
28 | } | ||
29 | |||
30 | // 40 = length of sha1 field hashed_given_url | ||
31 | $entryTable->addIndex(['user_id', 'hashed_given_url'], 'hashed_given_url_user_id', [], ['lengths' => [null, 40]]); | ||
32 | } | ||
33 | |||
34 | public function down(Schema $schema) | ||
35 | { | ||
36 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
37 | |||
38 | if ($entryTable->hasColumn('given_url')) { | ||
39 | $entryTable->dropColumn('given_url'); | ||
40 | } | ||
41 | |||
42 | if ($entryTable->hasColumn('hashed_given_url')) { | ||
43 | $entryTable->dropColumn('hashed_given_url'); | ||
44 | } | ||
45 | |||
46 | $entryTable->dropIndex('hashed_given_url_user_id'); | ||
47 | } | ||
48 | } | ||