3 namespace Application\Migrations
;
5 use Doctrine\DBAL\Migrations\SkipMigrationException
;
6 use Doctrine\DBAL\Schema\Schema
;
7 use Wallabag\CoreBundle\Doctrine\WallabagMigration
;
10 * Increase the length of the "quote" column of "annotation" table.
12 class Version20170511211659
extends WallabagMigration
14 public function up(Schema
$schema)
16 $tableName = $this->getTable('annotation');
18 switch ($this->connection
->getDatabasePlatform()->getName()) {
21 CREATE TEMPORARY TABLE __temp__wallabag_annotation AS
22 SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges
26 $this->addSql('DROP TABLE ' . $tableName);
28 CREATE TABLE ${tableName}
30 id INTEGER PRIMARY KEY NOT NULL,
31 user_id INTEGER DEFAULT NULL,
32 entry_id INTEGER DEFAULT NULL,
34 created_at DATETIME NOT NULL,
35 updated_at DATETIME NOT NULL,
38 CONSTRAINT FK_A7AED006A76ED395 FOREIGN KEY (user_id) REFERENCES wallabag_user (id),
39 CONSTRAINT FK_A7AED006BA364942 FOREIGN KEY (entry_id) REFERENCES wallabag_entry (id) ON DELETE CASCADE
41 CREATE INDEX IDX_A7AED006A76ED395 ON wallabag_annotation (user_id);
42 CREATE INDEX IDX_A7AED006BA364942 ON wallabag_annotation (entry_id);
47 INSERT INTO ${tableName} (id, user_id, entry_id, text, created_at, updated_at, quote, ranges)
48 SELECT id, user_id, entry_id, text, created_at, updated_at, quote, ranges
49 FROM __temp__wallabag_annotation;
52 $this->addSql('DROP TABLE __temp__wallabag_annotation');
55 $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote TEXT NOT NULL');
58 $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE TEXT');
63 public function down(Schema
$schema)
65 $tableName = $this->getTable('annotation');
67 switch ($this->connection
->getDatabasePlatform()->getName()) {
69 throw new SkipMigrationException('Too complex ...');
72 $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote VARCHAR(255) NOT NULL');
75 $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE VARCHAR(255)');