]> git.immae.eu Git - github/wallabag/wallabag.git/blame - app/DoctrineMigrations/Version20180405182455.php
Fix utf8mb4 on vendor tables
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20180405182455.php
CommitLineData
7975395d
SV
1<?php
2
3namespace Application\Migrations;
4
7975395d 5use Doctrine\DBAL\Schema\Schema;
877787e5 6use Wallabag\CoreBundle\Doctrine\WallabagMigration;
7975395d
SV
7
8/**
9 * Add archived_at column and set its value to updated_at for is_archived entries.
10 */
877787e5 11class Version20180405182455 extends WallabagMigration
7975395d 12{
7975395d
SV
13 /**
14 * @param Schema $schema
15 */
16 public function up(Schema $schema)
17 {
18 $entryTable = $schema->getTable($this->getTable('entry'));
19
20 $this->skipIf($entryTable->hasColumn('archived_at'), 'It seems that you already played this migration.');
21
22 $entryTable->addColumn('archived_at', 'datetime', [
23 'notnull' => false,
24 ]);
25 }
26
27 public function postUp(Schema $schema)
28 {
29 $entryTable = $schema->getTable($this->getTable('entry'));
30 $this->skipIf(!$entryTable->hasColumn('archived_at'), 'Unable to add archived_at colum');
31
32 $this->connection->executeQuery(
33 'UPDATE ' . $this->getTable('entry') . ' SET archived_at = updated_at WHERE is_archived = :is_archived',
34 [
35 'is_archived' => true,
36 ]
37 );
38 }
39
40 /**
41 * @param Schema $schema
42 */
43 public function down(Schema $schema)
44 {
45 $entryTable = $schema->getTable($this->getTable('entry'));
46
47 $this->skipIf(!$entryTable->hasColumn('archived_at'), 'It seems that you already played this migration.');
48
49 $entryTable->dropColumn('archived_at');
50 }
7975395d 51}