diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-04-01 11:50:33 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-04-01 13:24:40 +0200 |
commit | 9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c (patch) | |
tree | b8b37a0f8b3edd0c4db1678815d906a7b6126f31 /app | |
parent | bfe02a0b481055bb4e799200c8daa9a0ad987c71 (diff) | |
download | wallabag-9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c.tar.gz wallabag-9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c.tar.zst wallabag-9c2b2aae70b06411336e6eb6ac43b3ebd30dc38c.zip |
Keep url in exists endpoint
- Add migration
- Use md5 instead of sha512 (we don't need security here, just a hash)
- Update tests
Diffstat (limited to 'app')
-rw-r--r-- | app/DoctrineMigrations/Version20190401105353.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20190401105353.php b/app/DoctrineMigrations/Version20190401105353.php new file mode 100644 index 00000000..4afc8b15 --- /dev/null +++ b/app/DoctrineMigrations/Version20190401105353.php | |||
@@ -0,0 +1,44 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Schema\Schema; | ||
6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; | ||
7 | |||
8 | /** | ||
9 | * Add hashed_url in entry. | ||
10 | */ | ||
11 | class Version20190401105353 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 | $this->skipIf($entryTable->hasColumn('hashed_url'), 'It seems that you already played this migration.'); | ||
21 | |||
22 | $entryTable->addColumn('hashed_url', 'text', [ | ||
23 | 'length' => 32, | ||
24 | 'notnull' => false, | ||
25 | ]); | ||
26 | |||
27 | // sqlite doesn't have the MD5 function by default | ||
28 | if ('sqlite' !== $this->connection->getDatabasePlatform()->getName()) { | ||
29 | $this->addSql('UPDATE ' . $this->getTable('entry') . ' SET hashed_url = MD5(url)'); | ||
30 | } | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * @param Schema $schema | ||
35 | */ | ||
36 | public function down(Schema $schema) | ||
37 | { | ||
38 | $entryTable = $schema->getTable($this->getTable('entry')); | ||
39 | |||
40 | $this->skipIf(!$entryTable->hasColumn('hashed_url'), 'It seems that you already played this migration.'); | ||
41 | |||
42 | $entryTable->dropColumn('hashed_url'); | ||
43 | } | ||
44 | } | ||