Skip to content

Commit f847f72

Browse files
committed
2.0.1 softer upgrading from 1.x
1 parent d4b5294 commit f847f72

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

code/Module.class.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class Module extends FormToolsModule
1616
protected $author = "Ben Keen";
1717
protected $authorEmail = "[email protected]";
1818
protected $authorLink = "https://formtools.org";
19-
protected $version = "2.0.0";
20-
protected $date = "2017-12-26";
19+
protected $version = "2.0.1";
20+
protected $date = "2018-02-17";
2121
protected $originLanguage = "en_us";
2222
protected $cssFiles = array("{MODULEROOT}/css/styles.css");
2323

@@ -156,14 +156,27 @@ public function upgrade($old_version_info, $new_version_info)
156156
$db->execute();
157157
}
158158

159-
if ($old_version_date < 20110930) {
159+
if (!self::checkColumnExists("module_submission_accounts", "swatch")) {
160160
$db->query("ALTER TABLE {PREFIX}module_submission_accounts ADD swatch VARCHAR(255) NULL AFTER theme");
161161
$db->execute();
162+
}
162163

164+
if ($old_version_date < 20110930) {
163165
$db->query("UPDATE {PREFIX}module_submission_accounts SET swatch = 'green' WHERE theme = 'default'");
164166
$db->execute();
165167
}
166168

167169
return array(true, "");
168170
}
171+
172+
// move to core
173+
private static function checkColumnExists($table_name, $column_name)
174+
{
175+
$db = Core::$db;
176+
177+
$db->query("SHOW COLUMNS FROM {PREFIX}$table_name LIKE '$column_name'");
178+
$db->execute();
179+
180+
return !empty($db->fetch());
181+
}
169182
}

0 commit comments

Comments
 (0)