diff options
-rw-r--r-- | app/DoctrineMigrations/Version20190129120000.php | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20190129120000.php b/app/DoctrineMigrations/Version20190129120000.php new file mode 100644 index 00000000..3632e762 --- /dev/null +++ b/app/DoctrineMigrations/Version20190129120000.php | |||
@@ -0,0 +1,147 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Schema\Schema; | ||
6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; | ||
7 | |||
8 | /** | ||
9 | * Add missing entries in craue_config_setting. | ||
10 | */ | ||
11 | final class Version20190129120000 extends WallabagMigration | ||
12 | { | ||
13 | private $settings = [ | ||
14 | [ | ||
15 | 'name' => 'carrot', | ||
16 | 'value' => '1', | ||
17 | 'section' => 'entry', | ||
18 | ], | ||
19 | [ | ||
20 | 'name' => 'share_diaspora', | ||
21 | 'value' => '1', | ||
22 | 'section' => 'entry', | ||
23 | ], | ||
24 | [ | ||
25 | 'name' => 'diaspora_url', | ||
26 | 'value' => 'http://diasporapod.com', | ||
27 | 'section' => 'entry', | ||
28 | ], | ||
29 | [ | ||
30 | 'name' => 'share_shaarli', | ||
31 | 'value' => '1', | ||
32 | 'section' => 'entry', | ||
33 | ], | ||
34 | [ | ||
35 | 'name' => 'shaarli_url', | ||
36 | 'value' => 'http://myshaarli.com', | ||
37 | 'section' => 'entry', | ||
38 | ], | ||
39 | [ | ||
40 | 'name' => 'share_mail', | ||
41 | 'value' => '1', | ||
42 | 'section' => 'entry', | ||
43 | ], | ||
44 | [ | ||
45 | 'name' => 'share_twitter', | ||
46 | 'value' => '1', | ||
47 | 'section' => 'entry', | ||
48 | ], | ||
49 | [ | ||
50 | 'name' => 'show_printlink', | ||
51 | 'value' => '1', | ||
52 | 'section' => 'entry', | ||
53 | ], | ||
54 | [ | ||
55 | 'name' => 'export_epub', | ||
56 | 'value' => '1', | ||
57 | 'section' => 'export', | ||
58 | ], | ||
59 | [ | ||
60 | 'name' => 'export_mobi', | ||
61 | 'value' => '1', | ||
62 | 'section' => 'export', | ||
63 | ], | ||
64 | [ | ||
65 | 'name' => 'export_pdf', | ||
66 | 'value' => '1', | ||
67 | 'section' => 'export', | ||
68 | ], | ||
69 | [ | ||
70 | 'name' => 'export_csv', | ||
71 | 'value' => '1', | ||
72 | 'section' => 'export', | ||
73 | ], | ||
74 | [ | ||
75 | 'name' => 'export_json', | ||
76 | 'value' => '1', | ||
77 | 'section' => 'export', | ||
78 | ], | ||
79 | [ | ||
80 | 'name' => 'export_txt', | ||
81 | 'value' => '1', | ||
82 | 'section' => 'export', | ||
83 | ], | ||
84 | [ | ||
85 | 'name' => 'export_xml', | ||
86 | 'value' => '1', | ||
87 | 'section' => 'export', | ||
88 | ], | ||
89 | [ | ||
90 | 'name' => 'piwik_enabled', | ||
91 | 'value' => '0', | ||
92 | 'section' => 'analytics', | ||
93 | ], | ||
94 | [ | ||
95 | 'name' => 'piwik_host', | ||
96 | 'value' => 'v2.wallabag.org', | ||
97 | 'section' => 'analytics', | ||
98 | ], | ||
99 | [ | ||
100 | 'name' => 'piwik_site_id', | ||
101 | 'value' => '1', | ||
102 | 'section' => 'analytics', | ||
103 | ], | ||
104 | [ | ||
105 | 'name' => 'demo_mode_enabled', | ||
106 | 'value' => '0', | ||
107 | 'section' => 'misc', | ||
108 | ], | ||
109 | [ | ||
110 | 'name' => 'demo_mode_username', | ||
111 | 'value' => 'wallabag', | ||
112 | 'section' => 'misc', | ||
113 | ], | ||
114 | [ | ||
115 | 'name' => 'wallabag_support_url', | ||
116 | 'value' => 'https://www.wallabag.org/pages/support.html', | ||
117 | 'section' => 'misc', | ||
118 | ], | ||
119 | ]; | ||
120 | |||
121 | /** | ||
122 | * @param Schema $schema | ||
123 | */ | ||
124 | public function up(Schema $schema) | ||
125 | { | ||
126 | foreach ($this->settings as $setting) { | ||
127 | $settingEnabled = $this->container | ||
128 | ->get('doctrine.orm.default_entity_manager') | ||
129 | ->getConnection() | ||
130 | ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = '" . $setting['name'] . "'"); | ||
131 | |||
132 | if (false !== $settingEnabled) { | ||
133 | continue; | ||
134 | } | ||
135 | |||
136 | $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('" . $setting['name'] . "', '" . $setting['value'] . "', '" . $setting['section'] . "');"); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | * @param Schema $schema | ||
142 | */ | ||
143 | public function down(Schema $schema) | ||
144 | { | ||
145 | $this->skipIf(true, 'These settings are required and should not be removed.'); | ||
146 | } | ||
147 | } | ||