From b7fa51ae7dd5fef2d9459100c88479413ddd3fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 10 Jul 2017 21:32:25 +0200 Subject: Added given_url in entry table - Added index on entry table for given_url field - Fix tests: The previous `bit.ly` url redirected to doc.wallabag but that url doesn't exist in the fixtures. I used our own internal "redirector" to create a redirect to an url which exist in the fixtures. Also, updating current migration to use the new `WallabagMigration`. --- app/DoctrineMigrations/Version20170710125843.php | 38 +++++++++++++++++++ app/DoctrineMigrations/Version20171218135243.php | 48 ++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 app/DoctrineMigrations/Version20170710125843.php create mode 100644 app/DoctrineMigrations/Version20171218135243.php (limited to 'app') diff --git a/app/DoctrineMigrations/Version20170710125843.php b/app/DoctrineMigrations/Version20170710125843.php new file mode 100644 index 00000000..2cf8647a --- /dev/null +++ b/app/DoctrineMigrations/Version20170710125843.php @@ -0,0 +1,38 @@ +getTable($this->getTable('entry')); + + $this->skipIf($entryTable->hasColumn('given_url'), 'It seems that you already played this migration.'); + + $entryTable->addColumn('given_url', 'text', [ + 'notnull' => false, + ]); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $entryTable = $schema->getTable($this->getTable('entry')); + + $this->skipIf(!$entryTable->hasColumn('given_url'), 'It seems that you already played this migration.'); + + $entryTable->dropColumn('given_url'); + } +} diff --git a/app/DoctrineMigrations/Version20171218135243.php b/app/DoctrineMigrations/Version20171218135243.php new file mode 100644 index 00000000..3060c920 --- /dev/null +++ b/app/DoctrineMigrations/Version20171218135243.php @@ -0,0 +1,48 @@ +getTable($this->getTable('entry')); + $this->skipIf($entryTable->hasIndex($this->indexGivenUrl), 'It seems that you already played this migration.'); + + switch ($this->connection->getDatabasePlatform()->getName()) { + case 'sqlite': + $sql = 'CREATE UNIQUE INDEX ' . $this->indexGivenUrl . ' ON ' . $this->getTable('entry') . ' (url, given_url, user_id);'; + break; + case 'mysql': + $sql = 'CREATE UNIQUE INDEX ' . $this->indexGivenUrl . ' ON ' . $this->getTable('entry') . ' (url (255), given_url (255), user_id);'; + break; + case 'postgresql': + $sql = 'CREATE UNIQUE INDEX ' . $this->indexGivenUrl . ' ON ' . $this->getTable('entry') . ' (url, given_url, user_id);'; + break; + } + + $this->addSql($sql); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $entryTable = $schema->getTable($this->getTable('entry')); + $this->skipIf(false === $entryTable->hasIndex($this->indexGivenUrl), 'It seems that you already played this migration.'); + + $entryTable->dropIndex($this->indexGivenUrl); + } +} -- cgit v1.2.3