From c2efb5a3069b59341667626beb0fd6223a98189d Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 29 Jan 2019 14:24:38 +0100 Subject: Add missing entries in craue_config_setting. Should fix https://github.com/wallabag/wallabag/issues/3662 --- app/DoctrineMigrations/Version20190129120000.php | 74 ++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 app/DoctrineMigrations/Version20190129120000.php diff --git a/app/DoctrineMigrations/Version20190129120000.php b/app/DoctrineMigrations/Version20190129120000.php new file mode 100644 index 00000000..61e0ef4c --- /dev/null +++ b/app/DoctrineMigrations/Version20190129120000.php @@ -0,0 +1,74 @@ + "carrot", "value" => "1", "section" => "entry"), + array("name" => "share_diaspora", "value" => "1", "section" => "entry"), + array("name" => "diaspora_url", "value" => "http://diasporapod.com", "section" => "entry"), + array("name" => "share_shaarli", "value" => "1", "section" => "entry"), + array("name" => "shaarli_url", "value" => "http://myshaarli.com", "section" => "entry"), + array("name" => "share_mail", "value" => "1", "section" => "entry"), + array("name" => "share_twitter", "value" => "1", "section" => "entry"), + array("name" => "show_printlink", "value" => "1", "section" => "entry"), + array("name" => "export_epub", "value" => "1", "section" => "export"), + array("name" => "export_mobi", "value" => "1", "section" => "export"), + array("name" => "export_pdf", "value" => "1", "section" => "export"), + array("name" => "export_csv", "value" => "1", "section" => "export"), + array("name" => "export_json", "value" => "1", "section" => "export"), + array("name" => "export_txt", "value" => "1", "section" => "export"), + array("name" => "export_xml", "value" => "1", "section" => "export"), + array("name" => "piwik_enabled", "value" => "0", "section" => "analytics"), + array("name" => "piwik_host", "value" => "v2.wallabag.org", "section" => "analytics"), + array("name" => "piwik_site_id", "value" => "1", "section" => "analytics"), + array("name" => "demo_mode_enabled", "value" => "0", "section" => "misc"), + array("name" => "demo_mode_username", "value" => "wallabag", "section" => "misc"), + array("name" => "wallabag_support_url", "value" => "https://www.wallabag.org/pages/support.html", "section" => "misc"), + ); + + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + $piwikEnabled = $this->container + ->get('doctrine.orm.default_entity_manager') + ->getConnection() + ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'piwik_enabled'"); + + $this->skipIf(false !== $piwikEnabled, 'It seems that you already played this migration, or user the wallabag:install command.'); + + foreach ($this->settings as $setting) { + $this->addSql(" + INSERT INTO " . $this->getTable('craue_config_setting') . " + (name, value, section) + VALUES ( + '" . $setting['name'] . "', + '" . $setting['value'] . "', + '" . $setting['section'] . "' + ); + "); + } + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + foreach ($this->settings as $setting) { + $this->addSql(" + DELETE FROM " . $this->getTable('craue_config_setting') . " + WHERE name = '" . $setting['name'] . "'; + "); + } + } +} -- cgit v1.2.3 From fcd54e2447332a681f5b1fde7e737ea5a8975823 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 27 Feb 2019 13:39:17 +0100 Subject: Test each internal settings before creating them --- app/DoctrineMigrations/Version20190129120000.php | 160 +++++++++++++++++------ 1 file changed, 119 insertions(+), 41 deletions(-) diff --git a/app/DoctrineMigrations/Version20190129120000.php b/app/DoctrineMigrations/Version20190129120000.php index 61e0ef4c..5f25d67d 100644 --- a/app/DoctrineMigrations/Version20190129120000.php +++ b/app/DoctrineMigrations/Version20190129120000.php @@ -8,54 +8,132 @@ use Wallabag\CoreBundle\Doctrine\WallabagMigration; /** * Add missing entries in craue_config_setting. */ -class Version20190129120000 extends WallabagMigration +final class Version20190129120000 extends WallabagMigration { - var $settings = array( - array("name" => "carrot", "value" => "1", "section" => "entry"), - array("name" => "share_diaspora", "value" => "1", "section" => "entry"), - array("name" => "diaspora_url", "value" => "http://diasporapod.com", "section" => "entry"), - array("name" => "share_shaarli", "value" => "1", "section" => "entry"), - array("name" => "shaarli_url", "value" => "http://myshaarli.com", "section" => "entry"), - array("name" => "share_mail", "value" => "1", "section" => "entry"), - array("name" => "share_twitter", "value" => "1", "section" => "entry"), - array("name" => "show_printlink", "value" => "1", "section" => "entry"), - array("name" => "export_epub", "value" => "1", "section" => "export"), - array("name" => "export_mobi", "value" => "1", "section" => "export"), - array("name" => "export_pdf", "value" => "1", "section" => "export"), - array("name" => "export_csv", "value" => "1", "section" => "export"), - array("name" => "export_json", "value" => "1", "section" => "export"), - array("name" => "export_txt", "value" => "1", "section" => "export"), - array("name" => "export_xml", "value" => "1", "section" => "export"), - array("name" => "piwik_enabled", "value" => "0", "section" => "analytics"), - array("name" => "piwik_host", "value" => "v2.wallabag.org", "section" => "analytics"), - array("name" => "piwik_site_id", "value" => "1", "section" => "analytics"), - array("name" => "demo_mode_enabled", "value" => "0", "section" => "misc"), - array("name" => "demo_mode_username", "value" => "wallabag", "section" => "misc"), - array("name" => "wallabag_support_url", "value" => "https://www.wallabag.org/pages/support.html", "section" => "misc"), - ); + private $settings = [ + [ + 'name' => 'carrot', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'share_diaspora', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'diaspora_url', + 'value' => 'http://diasporapod.com', + 'section' => 'entry', + ], + [ + 'name' => 'share_shaarli', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'shaarli_url', + 'value' => 'http://myshaarli.com', + 'section' => 'entry', + ], + [ + 'name' => 'share_mail', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'share_twitter', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'show_printlink', + 'value' => '1', + 'section' => 'entry', + ], + [ + 'name' => 'export_epub', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_mobi', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_pdf', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_csv', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_json', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_txt', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'export_xml', + 'value' => '1', + 'section' => 'export', + ], + [ + 'name' => 'piwik_enabled', + 'value' => '0', + 'section' => 'analytics', + ], + [ + 'name' => 'piwik_host', + 'value' => 'v2.wallabag.org', + 'section' => 'analytics', + ], + [ + 'name' => 'piwik_site_id', + 'value' => '1', + 'section' => 'analytics', + ], + [ + 'name' => 'demo_mode_enabled', + 'value' => '0', + 'section' => 'misc', + ], + [ + 'name' => 'demo_mode_username', + 'value' => 'wallabag', + 'section' => 'misc', + ], + [ + 'name' => 'wallabag_support_url', + 'value' => 'https://www.wallabag.org/pages/support.html', + 'section' => 'misc', + ], + ]; /** * @param Schema $schema */ public function up(Schema $schema) { - $piwikEnabled = $this->container - ->get('doctrine.orm.default_entity_manager') - ->getConnection() - ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'piwik_enabled'"); + foreach ($this->settings as $setting) { + $settingEnabled = $this->container + ->get('doctrine.orm.default_entity_manager') + ->getConnection() + ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = '" . $setting['name'] . "'"); - $this->skipIf(false !== $piwikEnabled, 'It seems that you already played this migration, or user the wallabag:install command.'); + if (false !== $settingEnabled) { + continue; + } - foreach ($this->settings as $setting) { - $this->addSql(" - INSERT INTO " . $this->getTable('craue_config_setting') . " - (name, value, section) - VALUES ( - '" . $setting['name'] . "', - '" . $setting['value'] . "', - '" . $setting['section'] . "' - ); - "); + $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('" . $setting['name'] . "', '" . $setting['value'] . "', '" . $setting['section'] . "');"); } } @@ -65,8 +143,8 @@ class Version20190129120000 extends WallabagMigration public function down(Schema $schema) { foreach ($this->settings as $setting) { - $this->addSql(" - DELETE FROM " . $this->getTable('craue_config_setting') . " + $this->addSql(' + DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = '" . $setting['name'] . "'; "); } -- cgit v1.2.3 From 85403dae0463660f86de68970dcd1a5cbe784a31 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 1 Mar 2019 20:26:51 +0100 Subject: Disable down for that migration --- app/DoctrineMigrations/Version20190129120000.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/DoctrineMigrations/Version20190129120000.php b/app/DoctrineMigrations/Version20190129120000.php index 5f25d67d..3632e762 100644 --- a/app/DoctrineMigrations/Version20190129120000.php +++ b/app/DoctrineMigrations/Version20190129120000.php @@ -142,11 +142,6 @@ final class Version20190129120000 extends WallabagMigration */ public function down(Schema $schema) { - foreach ($this->settings as $setting) { - $this->addSql(' - DELETE FROM ' . $this->getTable('craue_config_setting') . " - WHERE name = '" . $setting['name'] . "'; - "); - } + $this->skipIf(true, 'These settings are required and should not be removed.'); } } -- cgit v1.2.3