upgrade_1835_mysql: fix defaults for both date fields at once

Doing it in two steps fails, see comment by Gabor 'Morc' KORMOS on
https://sourceforge.net/p/postfixadmin/bugs/5/

Note: This is an exception from the "never change an existing
upgrade_*() function" rule because
a) the result doesn't change for people where it worked and
b) it will continue here anyway for people who had upgrade problems


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1881 a1433add-5e2c-0410-b055-b7f2511e0802
pull/12/head
Christian Boltz 8 years ago
parent 74130b478c
commit 516f1c68f4

@ -1619,14 +1619,14 @@ function upgrade_1824_sqlite() {
function upgrade_1835_mysql() { function upgrade_1835_mysql() {
# change default values for existing datetime fields with a 0000-00-00 default to {DATETIME} # change default values for existing datetime fields with a 0000-00-00 default to {DATETIME}
foreach (array('admin', 'alias', 'alias_domain', 'domain', 'mailbox', 'domain_admins', 'vacation') as $table_to_change) { foreach (array('domain_admins', 'vacation') as $table_to_change) {
$table = table_by_key($table_to_change); $table = table_by_key($table_to_change);
db_query_parsed("ALTER TABLE `$table` CHANGE `created` `created` {DATETIME}"); db_query_parsed("ALTER TABLE `$table` CHANGE `created` `created` {DATETIME}");
} }
foreach (array('admin', 'alias', 'alias_domain', 'domain', 'mailbox') as $table_to_change) { foreach (array('admin', 'alias', 'alias_domain', 'domain', 'mailbox') as $table_to_change) {
$table = table_by_key($table_to_change); $table = table_by_key($table_to_change);
db_query_parsed("ALTER TABLE `$table` CHANGE `modified` `modified` {DATETIME}"); db_query_parsed("ALTER TABLE `$table` CHANGE `created` `created` {DATETIME}, CHANGE `modified` `modified` {DATETIME}");
} }
$table = table_by_key('log'); $table = table_by_key('log');

Loading…
Cancel
Save