Added indexes on is_archived and is_starred

This commit is contained in:
Nicolas Lœuillet 2017-01-27 11:44:04 +01:00
parent 6fb06904ec
commit b564d350b0
No known key found for this signature in database
GPG key ID: BDC1EFB5CA0145F2
7 changed files with 316 additions and 0 deletions

View file

@ -0,0 +1,58 @@
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Added indexes on wallabag_entry.is_starred and wallabag_entry.is_archived
*/
class Version20170127093841 extends AbstractMigration implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
private $container;
private $indexStarredName = 'IDX_entry_starred';
private $indexArchivedName = 'IDX_entry_archived';
public function setContainer(ContainerInterface $container = null)
{
$this->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);
}
}

View file

@ -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)

View file

@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -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)

View file

@ -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
===========================

View file

@ -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)

View file

@ -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é
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^