diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-04-01 13:51:57 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-04-01 13:51:57 +0200 |
commit | 8a6456629814039cfc623cdb279bcba06dacff50 (patch) | |
tree | b3ae2459651b6ad085588fca0c624c6df554deb3 /app/DoctrineMigrations/Version20190401105353.php | |
parent | 9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c (diff) | |
download | wallabag-8a6456629814039cfc623cdb279bcba06dacff50.tar.gz wallabag-8a6456629814039cfc623cdb279bcba06dacff50.tar.zst wallabag-8a6456629814039cfc623cdb279bcba06dacff50.zip |
Use a better index for hashed_url
It'll most often be used in addition to the `user_id`.
Also, automatically generate the hash when saving the url.
Switch from `md5` to `sha1`.
Diffstat (limited to 'app/DoctrineMigrations/Version20190401105353.php')
-rw-r--r-- | app/DoctrineMigrations/Version20190401105353.php | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/DoctrineMigrations/Version20190401105353.php b/app/DoctrineMigrations/Version20190401105353.php index 4afc8b15..c1c22053 100644 --- a/app/DoctrineMigrations/Version20190401105353.php +++ b/app/DoctrineMigrations/Version20190401105353.php | |||
@@ -20,7 +20,7 @@ class Version20190401105353 extends WallabagMigration | |||
20 | $this->skipIf($entryTable->hasColumn('hashed_url'), 'It seems that you already played this migration.'); | 20 | $this->skipIf($entryTable->hasColumn('hashed_url'), 'It seems that you already played this migration.'); |
21 | 21 | ||
22 | $entryTable->addColumn('hashed_url', 'text', [ | 22 | $entryTable->addColumn('hashed_url', 'text', [ |
23 | 'length' => 32, | 23 | 'length' => 40, |
24 | 'notnull' => false, | 24 | 'notnull' => false, |
25 | ]); | 25 | ]); |
26 | 26 | ||
@@ -28,6 +28,8 @@ class Version20190401105353 extends WallabagMigration | |||
28 | if ('sqlite' !== $this->connection->getDatabasePlatform()->getName()) { | 28 | if ('sqlite' !== $this->connection->getDatabasePlatform()->getName()) { |
29 | $this->addSql('UPDATE ' . $this->getTable('entry') . ' SET hashed_url = MD5(url)'); | 29 | $this->addSql('UPDATE ' . $this->getTable('entry') . ' SET hashed_url = MD5(url)'); |
30 | } | 30 | } |
31 | |||
32 | $entryTable->addIndex(['user_id', 'hashed_url'], 'hashed_url_user_id'); | ||
31 | } | 33 | } |
32 | 34 | ||
33 | /** | 35 | /** |
@@ -39,6 +41,7 @@ class Version20190401105353 extends WallabagMigration | |||
39 | 41 | ||
40 | $this->skipIf(!$entryTable->hasColumn('hashed_url'), 'It seems that you already played this migration.'); | 42 | $this->skipIf(!$entryTable->hasColumn('hashed_url'), 'It seems that you already played this migration.'); |
41 | 43 | ||
44 | $entryTable->dropIndex('hashed_url_user_id'); | ||
42 | $entryTable->dropColumn('hashed_url'); | 45 | $entryTable->dropColumn('hashed_url'); |
43 | } | 46 | } |
44 | } | 47 | } |