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