From 8a21985474c2daae9f84ac52463fe7d297aae3ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 20 Nov 2017 17:39:14 +0100 Subject: Added internal setting to enable/disable headers storage --- app/DoctrineMigrations/Version20171120163128.php | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 app/DoctrineMigrations/Version20171120163128.php (limited to 'app/DoctrineMigrations/Version20171120163128.php') diff --git a/app/DoctrineMigrations/Version20171120163128.php b/app/DoctrineMigrations/Version20171120163128.php new file mode 100644 index 00000000..fc3d4c37 --- /dev/null +++ b/app/DoctrineMigrations/Version20171120163128.php @@ -0,0 +1,52 @@ +container = $container; + } + + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + $storeArticleHeaders = $this->container + ->get('doctrine.orm.default_entity_manager') + ->getConnection() + ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'store_article_headers'"); + + $this->skipIf(false !== $storeArticleHeaders, 'It seems that you already played this migration.'); + + $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('store_article_headers', '0', 'entry')"); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'store_article_headers';"); + } + + private function getTable($tableName) + { + return $this->container->getParameter('database_table_prefix') . $tableName; + } +} -- cgit v1.2.3