]> git.immae.eu Git - github/wallabag/wallabag.git/blame - app/DoctrineMigrations/Version20160410190541.php
Merge pull request #4438 from wallabag/dependabot/composer/scheb/two-factor-bundle...
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20160410190541.php
CommitLineData
d0545b6b
NL
1<?php
2
3namespace Application\Migrations;
4
d0545b6b 5use Doctrine\DBAL\Schema\Schema;
bfe7a692 6use Wallabag\CoreBundle\Doctrine\WallabagMigration;
d0545b6b 7
b87f1712 8/**
01736b5a 9 * Added foreign keys for account resetting.
b87f1712 10 */
bfe7a692 11class Version20160410190541 extends WallabagMigration
d0545b6b 12{
d0545b6b
NL
13 public function up(Schema $schema)
14 {
597755b8 15 $entryTable = $schema->getTable($this->getTable('entry'));
73f7eabb 16
a5cd696b 17 $this->skipIf($entryTable->hasColumn('uid') || $entryTable->hasColumn('uuid'), 'It seems that you already played this migration.');
4c79c51f 18
7239082a 19 $entryTable->addColumn('uid', 'string', [
597755b8 20 'notnull' => false,
89cd670a 21 'length' => 23,
597755b8 22 ]);
7a340375
NL
23
24 $sharePublic = $this->container
25 ->get('doctrine.orm.default_entity_manager')
26 ->getConnection()
f808b016 27 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_public'");
7a340375
NL
28
29 if (false === $sharePublic) {
f808b016 30 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_public', '1', 'entry')");
7a340375 31 }
9a5231e8 32 }
a7e2218e 33
d0545b6b
NL
34 public function down(Schema $schema)
35 {
597755b8 36 $entryTable = $schema->getTable($this->getTable('entry'));
7239082a 37 $entryTable->dropColumn('uid');
ad9304cd 38
f808b016
JB
39 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_public'");
40 }
d0545b6b 41}