]> git.immae.eu Git - github/wallabag/wallabag.git/blame - app/DoctrineMigrations/Version20161031132655.php
Added publication date
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20161031132655.php
CommitLineData
aedd6ca0
JB
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
b87f1712 10/**
5e9009ce 11 * Added the internal setting to enable/disable downloading pictures.
b87f1712 12 */
aedd6ca0
JB
13class Version20161031132655 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 public function setContainer(ContainerInterface $container = null)
21 {
22 $this->container = $container;
23 }
24
25 private function getTable($tableName)
26 {
a4d55a91 27 return $this->container->getParameter('database_table_prefix').$tableName;
aedd6ca0
JB
28 }
29
30 /**
31 * @param Schema $schema
32 */
33 public function up(Schema $schema)
34 {
31fec5f3
JB
35 $images = $this->container
36 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection()
bea8d754 38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled'");
31fec5f3
JB
39
40 $this->skipIf(false !== $images, 'It seems that you already played this migration.');
41
a48b5d5a 42 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
aedd6ca0
JB
43 }
44
45 /**
46 * @param Schema $schema
47 */
48 public function down(Schema $schema)
49 {
a48b5d5a 50 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled';");
aedd6ca0
JB
51 }
52}