3 namespace Application\Migrations
;
5 use Doctrine\DBAL\Schema\Schema
;
6 use Wallabag\CoreBundle\Doctrine\WallabagMigration
;
9 * Add archived_at column and set its value to updated_at for is_archived entries.
11 class Version20180405182455
extends WallabagMigration
14 * @param Schema $schema
16 public function up(Schema
$schema)
18 $entryTable = $schema->getTable($this->getTable('entry'));
20 $this->skipIf($entryTable->hasColumn('archived_at'), 'It seems that you already played this migration.');
22 $entryTable->addColumn('archived_at', 'datetime', [
27 public function postUp(Schema
$schema)
29 $entryTable = $schema->getTable($this->getTable('entry'));
30 $this->skipIf(!$entryTable->hasColumn('archived_at'), 'Unable to add archived_at colum');
32 $this->connection
->executeQuery(
33 'UPDATE ' . $this->getTable('entry') . ' SET archived_at = updated_at WHERE is_archived = :is_archived',
35 'is_archived' => true,
41 * @param Schema $schema
43 public function down(Schema
$schema)
45 $entryTable = $schema->getTable($this->getTable('entry'));
47 $this->skipIf(!$entryTable->hasColumn('archived_at'), 'It seems that you already played this migration.');
49 $entryTable->dropColumn('archived_at');