3 namespace Application\Migrations
;
5 use Doctrine\DBAL\Schema\Schema
;
6 use Wallabag\CoreBundle\Doctrine\WallabagMigration
;
9 * Add starred_at column and set its value to updated_at for is_starred entries.
11 class Version20170824113337
extends WallabagMigration
13 public function up(Schema
$schema)
15 $entryTable = $schema->getTable($this->getTable('entry'));
17 $this->skipIf($entryTable->hasColumn('starred_at'), 'It seems that you already played this migration.');
19 $entryTable->addColumn('starred_at', 'datetime', [
24 public function postUp(Schema
$schema)
26 $entryTable = $schema->getTable($this->getTable('entry'));
27 $this->skipIf(!$entryTable->hasColumn('starred_at'), 'Unable to add starred_at colum');
29 $this->connection
->executeQuery(
30 'UPDATE ' . $this->getTable('entry') . ' SET starred_at = updated_at WHERE is_starred = :is_starred',
37 public function down(Schema
$schema)
39 $entryTable = $schema->getTable($this->getTable('entry'));
41 $this->skipIf(!$entryTable->hasColumn('starred_at'), 'It seems that you already played this migration.');
43 $entryTable->dropColumn('starred_at');