From 1e7b04d4eada9b1a9064cbd8c9bf2de63ae63e76 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 4 Nov 2016 07:56:04 +0100 Subject: Use created_at as default sort With index (following https://github.com/wallabag/wallabag/pull/2534) --- app/DoctrineMigrations/Version20161104073720.php | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 app/DoctrineMigrations/Version20161104073720.php (limited to 'app/DoctrineMigrations/Version20161104073720.php') diff --git a/app/DoctrineMigrations/Version20161104073720.php b/app/DoctrineMigrations/Version20161104073720.php new file mode 100644 index 00000000..16503b4b --- /dev/null +++ b/app/DoctrineMigrations/Version20161104073720.php @@ -0,0 +1,53 @@ +container = $container; + } + + private function getTable($tableName) + { + return $this->container->getParameter('database_table_prefix') . $tableName; + } + + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + switch ($this->connection->getDatabasePlatform()->getName()) { + case 'sqlite': + $this->addSql('CREATE INDEX `created_at` ON `'.$this->getTable('entry').'` (`created_at` DESC)'); + break; + + case 'mysql': + $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD INDEX created_at (created_at);'); + break; + + case 'postgresql': + $this->addSql('CREATE INDEX created_at ON '.$this->getTable('entry').' (created_at DESC)'); + } + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + + } +} -- cgit v1.2.3