]> git.immae.eu Git - github/wallabag/wallabag.git/blob - app/DoctrineMigrations/Version20160410190541.php
Fixed migrations with dash into db name
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20160410190541.php
1 <?php
2
3 namespace Application\Migrations;
4
5 use Doctrine\DBAL\Schema\Schema;
6 use Wallabag\CoreBundle\Doctrine\WallabagMigration;
7
8 /**
9 * Added foreign keys for account resetting.
10 */
11 class Version20160410190541 extends WallabagMigration
12 {
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('uid') || $entryTable->hasColumn('uuid'), 'It seems that you already played this migration.');
21
22 $entryTable->addColumn('uid', 'string', [
23 'notnull' => false,
24 'length' => 23,
25 ]);
26
27 $sharePublic = $this->container
28 ->get('doctrine.orm.default_entity_manager')
29 ->getConnection()
30 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_public'");
31
32 if (false === $sharePublic) {
33 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_public', '1', 'entry')");
34 }
35 }
36
37 /**
38 * @param Schema $schema
39 */
40 public function down(Schema $schema)
41 {
42 $entryTable = $schema->getTable($this->getTable('entry'));
43 $entryTable->dropColumn('uid');
44
45 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_public'");
46 }
47 }