From b564d350b0d3ca5f8b5928c87272c55ff3c92b19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 27 Jan 2017 11:44:04 +0100 Subject: [PATCH] Added indexes on is_archived and is_starred --- .../Version20170127093841.php | 58 +++++++++++++ docs/de/user/query-upgrade-21-22.rst | 82 +++++++++++++++++++ docs/de/user/upgrade.rst | 5 ++ docs/en/user/query-upgrade-21-22.rst | 82 +++++++++++++++++++ docs/en/user/upgrade.rst | 2 + docs/fr/user/query-upgrade-21-22.rst | 82 +++++++++++++++++++ docs/fr/user/upgrade.rst | 5 ++ 7 files changed, 316 insertions(+) create mode 100644 app/DoctrineMigrations/Version20170127093841.php diff --git a/app/DoctrineMigrations/Version20170127093841.php b/app/DoctrineMigrations/Version20170127093841.php new file mode 100644 index 00000000..384529a1 --- /dev/null +++ b/app/DoctrineMigrations/Version20170127093841.php @@ -0,0 +1,58 @@ +container = $container; + } + + private function getTable($tableName) + { + return $this->container->getParameter('database_table_prefix').$tableName; + } + + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + $entryTable = $schema->getTable($this->getTable('entry')); + $this->skipIf($entryTable->hasIndex($this->indexStarredName), 'It seems that you already played this migration.'); + $this->skipIf($entryTable->hasIndex($this->indexStarredName), 'It seems that you already played this migration.'); + + $entryTable->addIndex(['is_starred'], $this->indexStarredName); + $entryTable->addIndex(['is_archived'], $this->indexArchivedName); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $entryTable = $schema->getTable($this->getTable('entry')); + $this->skipIf(false === $entryTable->hasIndex($this->indexStarredName), 'It seems that you already played this migration.'); + $this->skipIf(false === $entryTable->hasIndex($this->indexStarredName), 'It seems that you already played this migration.'); + + $entryTable->dropIndex($this->indexStarredName); + $entryTable->dropIndex($this->indexArchivedName); + } +} diff --git a/docs/de/user/query-upgrade-21-22.rst b/docs/de/user/query-upgrade-21-22.rst index cd201dc2..f32d5a19 100644 --- a/docs/de/user/query-upgrade-21-22.rst +++ b/docs/de/user/query-upgrade-21-22.rst @@ -795,3 +795,85 @@ Migration down DROP TABLE __temp__wallabag_entry CREATE INDEX created_at_idx ON wallabag_entry (created_at) CREATE INDEX IDX_F4D18282A76ED395 ON wallabag_entry (user_id) + +Migration 20170127093841 +------------------------ + +MySQL +^^^^^ + +Migration up +"""""""""""" + +.. code-block:: sql + + CREATE INDEX IDX_entry_starred ON wallabag_entry (is_starred) + CREATE INDEX IDX_entry_archived ON wallabag_entry (is_archived) + +Migration down +"""""""""""""" + +.. code-block:: sql + + DROP INDEX IDX_entry_starred ON wallabag_entry + DROP INDEX IDX_entry_archived ON wallabag_entry + +PostgreSQL +^^^^^^^^^^ + +Migration up +"""""""""""" + +.. code-block:: sql + + CREATE INDEX IDX_entry_starred ON wallabag_entry (is_starred) + CREATE INDEX IDX_entry_archived ON wallabag_entry (is_archived) + +Migration down +"""""""""""""" + +.. code-block:: sql + + DROP INDEX IDX_entry_starred + DROP INDEX IDX_entry_archived + +SQLite +^^^^^^ + +Migration up +"""""""""""" + +.. code-block:: sql + + DROP INDEX uid + DROP INDEX created_at + DROP INDEX IDX_F4D18282A76ED395 + CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM wallabag_entry + DROP TABLE wallabag_entry + CREATE TABLE wallabag_entry (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid VARCHAR(23) DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT '0', http_status VARCHAR(3) DEFAULT NULL COLLATE BINARY, PRIMARY KEY(id)) + INSERT INTO wallabag_entry (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status) SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM __temp__wallabag_entry + DROP TABLE __temp__wallabag_entry + CREATE INDEX uid ON wallabag_entry (uid) + CREATE INDEX created_at ON wallabag_entry (created_at) + CREATE INDEX IDX_F4D18282A76ED395 ON wallabag_entry (user_id) + CREATE INDEX IDX_entry_starred ON wallabag_entry (is_starred) + CREATE INDEX IDX_entry_archived ON wallabag_entry (is_archived) + +Migration down +"""""""""""""" + +.. code-block:: sql + + DROP INDEX IDX_entry_archived + DROP INDEX IDX_entry_starred + DROP INDEX IDX_F4D18282A76ED395 + DROP INDEX created_at + DROP INDEX uid + CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM wallabag_entry + DROP TABLE wallabag_entry + CREATE TABLE wallabag_entry (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid VARCHAR(23) DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT '0', http_status VARCHAR(3) DEFAULT NULL COLLATE BINARY, PRIMARY KEY(id)) + INSERT INTO wallabag_entry (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status) SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM __temp__wallabag_entry + DROP TABLE __temp__wallabag_entry + CREATE INDEX IDX_F4D18282A76ED395 ON wallabag_entry (user_id) + CREATE INDEX created_at ON wallabag_entry (created_at) + CREATE INDEX uid ON wallabag_entry (uid) diff --git a/docs/de/user/upgrade.rst b/docs/de/user/upgrade.rst index 1107616e..544c7167 100644 --- a/docs/de/user/upgrade.rst +++ b/docs/de/user/upgrade.rst @@ -37,6 +37,11 @@ Dies ist die Migrationsliste von 2.1.x auf 2.2.0: * ``20161118134328``: ``http_status``-Feld zur ``entry``-Tabelle hinzugefügt * ``20161122144743``: Interne Einstellung für das (de-)aktivieren zum Holen von Artikeln mit einer Paywall hinzugefügt * ``20161122203647``: ``expired``- und ``credentials_expired``-Feld aus der ``user``-Tabelle entfernt +* ``20161128084725``: added ``list_mode`` field on ``config`` table +* ``20161128131503``: dropped ``locked``, ``credentials_expire_at`` and ``expires_at`` fields on ``user`` table +* ``20161214094402``: renamed ``uuid`` to ``uid`` on ``entry`` table +* ``20161214094403``: added ``uid`` index on ``entry`` table +* ``20170127093841``: added ``is_starred`` and ``is_archived`` indexes on ``entry`` table Upgrade auf einem Shared Hosting ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/en/user/query-upgrade-21-22.rst b/docs/en/user/query-upgrade-21-22.rst index cd201dc2..f32d5a19 100644 --- a/docs/en/user/query-upgrade-21-22.rst +++ b/docs/en/user/query-upgrade-21-22.rst @@ -795,3 +795,85 @@ Migration down DROP TABLE __temp__wallabag_entry CREATE INDEX created_at_idx ON wallabag_entry (created_at) CREATE INDEX IDX_F4D18282A76ED395 ON wallabag_entry (user_id) + +Migration 20170127093841 +------------------------ + +MySQL +^^^^^ + +Migration up +"""""""""""" + +.. code-block:: sql + + CREATE INDEX IDX_entry_starred ON wallabag_entry (is_starred) + CREATE INDEX IDX_entry_archived ON wallabag_entry (is_archived) + +Migration down +"""""""""""""" + +.. code-block:: sql + + DROP INDEX IDX_entry_starred ON wallabag_entry + DROP INDEX IDX_entry_archived ON wallabag_entry + +PostgreSQL +^^^^^^^^^^ + +Migration up +"""""""""""" + +.. code-block:: sql + + CREATE INDEX IDX_entry_starred ON wallabag_entry (is_starred) + CREATE INDEX IDX_entry_archived ON wallabag_entry (is_archived) + +Migration down +"""""""""""""" + +.. code-block:: sql + + DROP INDEX IDX_entry_starred + DROP INDEX IDX_entry_archived + +SQLite +^^^^^^ + +Migration up +"""""""""""" + +.. code-block:: sql + + DROP INDEX uid + DROP INDEX created_at + DROP INDEX IDX_F4D18282A76ED395 + CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM wallabag_entry + DROP TABLE wallabag_entry + CREATE TABLE wallabag_entry (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid VARCHAR(23) DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT '0', http_status VARCHAR(3) DEFAULT NULL COLLATE BINARY, PRIMARY KEY(id)) + INSERT INTO wallabag_entry (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status) SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM __temp__wallabag_entry + DROP TABLE __temp__wallabag_entry + CREATE INDEX uid ON wallabag_entry (uid) + CREATE INDEX created_at ON wallabag_entry (created_at) + CREATE INDEX IDX_F4D18282A76ED395 ON wallabag_entry (user_id) + CREATE INDEX IDX_entry_starred ON wallabag_entry (is_starred) + CREATE INDEX IDX_entry_archived ON wallabag_entry (is_archived) + +Migration down +"""""""""""""" + +.. code-block:: sql + + DROP INDEX IDX_entry_archived + DROP INDEX IDX_entry_starred + DROP INDEX IDX_F4D18282A76ED395 + DROP INDEX created_at + DROP INDEX uid + CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM wallabag_entry + DROP TABLE wallabag_entry + CREATE TABLE wallabag_entry (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid VARCHAR(23) DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT '0', http_status VARCHAR(3) DEFAULT NULL COLLATE BINARY, PRIMARY KEY(id)) + INSERT INTO wallabag_entry (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status) SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM __temp__wallabag_entry + DROP TABLE __temp__wallabag_entry + CREATE INDEX IDX_F4D18282A76ED395 ON wallabag_entry (user_id) + CREATE INDEX created_at ON wallabag_entry (created_at) + CREATE INDEX uid ON wallabag_entry (uid) diff --git a/docs/en/user/upgrade.rst b/docs/en/user/upgrade.rst index 99260e13..889b5300 100644 --- a/docs/en/user/upgrade.rst +++ b/docs/en/user/upgrade.rst @@ -43,7 +43,9 @@ Here is the migrations list for 2.1.x to 2.2.0 release: * ``20161122203647``: dropped ``expired`` and ``credentials_expired`` fields on ``user`` table * ``20161128084725``: added ``list_mode`` field on ``config`` table * ``20161128131503``: dropped ``locked``, ``credentials_expire_at`` and ``expires_at`` fields on ``user`` table +* ``20161214094402``: renamed ``uuid`` to ``uid`` on ``entry`` table * ``20161214094403``: added ``uid`` index on ``entry`` table +* ``20170127093841``: added ``is_starred`` and ``is_archived`` indexes on ``entry`` table Upgrade on a shared hosting =========================== diff --git a/docs/fr/user/query-upgrade-21-22.rst b/docs/fr/user/query-upgrade-21-22.rst index cd201dc2..f32d5a19 100644 --- a/docs/fr/user/query-upgrade-21-22.rst +++ b/docs/fr/user/query-upgrade-21-22.rst @@ -795,3 +795,85 @@ Migration down DROP TABLE __temp__wallabag_entry CREATE INDEX created_at_idx ON wallabag_entry (created_at) CREATE INDEX IDX_F4D18282A76ED395 ON wallabag_entry (user_id) + +Migration 20170127093841 +------------------------ + +MySQL +^^^^^ + +Migration up +"""""""""""" + +.. code-block:: sql + + CREATE INDEX IDX_entry_starred ON wallabag_entry (is_starred) + CREATE INDEX IDX_entry_archived ON wallabag_entry (is_archived) + +Migration down +"""""""""""""" + +.. code-block:: sql + + DROP INDEX IDX_entry_starred ON wallabag_entry + DROP INDEX IDX_entry_archived ON wallabag_entry + +PostgreSQL +^^^^^^^^^^ + +Migration up +"""""""""""" + +.. code-block:: sql + + CREATE INDEX IDX_entry_starred ON wallabag_entry (is_starred) + CREATE INDEX IDX_entry_archived ON wallabag_entry (is_archived) + +Migration down +"""""""""""""" + +.. code-block:: sql + + DROP INDEX IDX_entry_starred + DROP INDEX IDX_entry_archived + +SQLite +^^^^^^ + +Migration up +"""""""""""" + +.. code-block:: sql + + DROP INDEX uid + DROP INDEX created_at + DROP INDEX IDX_F4D18282A76ED395 + CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM wallabag_entry + DROP TABLE wallabag_entry + CREATE TABLE wallabag_entry (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid VARCHAR(23) DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT '0', http_status VARCHAR(3) DEFAULT NULL COLLATE BINARY, PRIMARY KEY(id)) + INSERT INTO wallabag_entry (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status) SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM __temp__wallabag_entry + DROP TABLE __temp__wallabag_entry + CREATE INDEX uid ON wallabag_entry (uid) + CREATE INDEX created_at ON wallabag_entry (created_at) + CREATE INDEX IDX_F4D18282A76ED395 ON wallabag_entry (user_id) + CREATE INDEX IDX_entry_starred ON wallabag_entry (is_starred) + CREATE INDEX IDX_entry_archived ON wallabag_entry (is_archived) + +Migration down +"""""""""""""" + +.. code-block:: sql + + DROP INDEX IDX_entry_archived + DROP INDEX IDX_entry_starred + DROP INDEX IDX_F4D18282A76ED395 + DROP INDEX created_at + DROP INDEX uid + CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM wallabag_entry + DROP TABLE wallabag_entry + CREATE TABLE wallabag_entry (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid VARCHAR(23) DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT '0', http_status VARCHAR(3) DEFAULT NULL COLLATE BINARY, PRIMARY KEY(id)) + INSERT INTO wallabag_entry (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status) SELECT id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public, http_status FROM __temp__wallabag_entry + DROP TABLE __temp__wallabag_entry + CREATE INDEX IDX_F4D18282A76ED395 ON wallabag_entry (user_id) + CREATE INDEX created_at ON wallabag_entry (created_at) + CREATE INDEX uid ON wallabag_entry (uid) diff --git a/docs/fr/user/upgrade.rst b/docs/fr/user/upgrade.rst index 088b19a0..2ca5d127 100644 --- a/docs/fr/user/upgrade.rst +++ b/docs/fr/user/upgrade.rst @@ -37,6 +37,11 @@ Voici la liste des migrations de la 2.1.x à la 2.2.0 : * ``20161118134328``: ajout du champ ``http_status`` sur la table ``entry`` * ``20161122144743``: ajout du paramètre interne pour activer/désactiver la récupération d'articles derrière un paywall * ``20161122203647``: suppression des champs ``expired`` et ``credentials_expired`` sur la table ``user`` +* ``20161128084725``: ajout du champ ``list_mode`` sur la table ``config`` +* ``20161128131503``: suppression des champs ``locked``, ``credentials_expire_at`` et ``expires_at`` sur la table ``user`` +* ``20161214094402``: renommage du champ ``uuid`` en ``uid`` sur la table ``entry`` +* ``20161214094403``: ajout de l'index ``uid`` sur la table ``entry`` +* ``20170127093841``: ajout des index ``is_starred`` et ``is_archived`` sur la table ``entry`` Mise à jour sur un hébergement mutualisé ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- 2.41.0