SF.net SVN: postfixadmin:[510] trunk/upgrade.php
Brought to you by:
christian_boltz,
gingerdog
|
From: <Gin...@us...> - 2009-01-12 20:53:55
|
Revision: 510
http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=510&view=rev
Author: GingerDog
Date: 2009-01-12 20:53:45 +0000 (Mon, 12 Jan 2009)
Log Message:
-----------
upgrade.php: add _mysql_field_exists() so we do not add fields that are already there; fix bugs -hopefully fix errors seen by Tom me...@td... - see postfixadmin-devel mailing list etc
Modified Paths:
--------------
trunk/upgrade.php
Modified: trunk/upgrade.php
===================================================================
--- trunk/upgrade.php 2009-01-07 19:59:33 UTC (rev 509)
+++ trunk/upgrade.php 2009-01-12 20:53:45 UTC (rev 510)
@@ -49,6 +49,15 @@
return false;
}
+function _mysql_field_exists($table, $field) {
+ $sql = "SHOW COLUMNS FROM $table LIKE '$field'";
+ $r = db_query($sql);
+ $row = db_row($r['result']);
+ if($row) {
+ return true;
+ }
+ return false;
+}
$table = table_by_key('config');
if($CONF['database_type'] == 'pgsql') {
@@ -772,7 +781,6 @@
# in case someone has manually created the table with utf8 fields before:
$all_sql = split("\n", trim("
- ALTER TABLE `$table_vacation_notification` CHANGE `on_vacation` `on_vacation` VARCHAR( 255 ) NOT NULL
ALTER TABLE `$table_vacation_notification` CHANGE `notified` `notified` VARCHAR( 255 ) NOT NULL
ALTER TABLE `$table_vacation_notification` DEFAULT CHARACTER SET utf8
"));
@@ -990,11 +998,15 @@
function upgrade_479_mysql () {
# ssl is a reserved word in MySQL and causes several problems. Renaming the field...
$table_fmail = table_by_key('fetchmail');
- db_query_parsed("ALTER TABLE `$table_fmail` CHANGE `ssl` `usessl` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'");
+ if(!_mysql_field_exists($table_fmail, 'usessl')) {
+ db_query_parsed("ALTER TABLE `$table_fmail` CHANGE `ssl` `usessl` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'");
+ }
}
function upgrade_479_pgsql () {
$table_fmail = table_by_key('fetchmail');
- db_query_parsed("alter table $table_fmail rename column ssl to usessl");
+ if(!_pgsql_field_exists($table_fmail, 'usessl')) {
+ db_query_parsed("alter table $table_fmail rename column ssl to usessl");
+ }
}
function upgrade_483_mysql () {
@@ -1016,9 +1028,11 @@
# See https://sourceforge.net/forum/message.php?msg_id=5394663
function upgrade_495_mysql() {
$table_mailbox = table_by_key('mailbox');
- db_query_parsed("ALTER TABLE $table_mailbox add local_part varchar(255) AFTER quota"); // allow to be null
- db_query_parsed("UPDATE $table_mailbox SET local_part = substring_index(username, '@', 1)");
- db_query_parsed("ALTER TABLE $table_mailbox change local_part local_part varchar(255) NOT NULL"); // remove null-ness...
+ if(!_mysql_field_exists($table_mailbox, 'local_part')) {
+ db_query_parsed("ALTER TABLE $table_mailbox add local_part varchar(255) AFTER quota"); // allow to be null
+ db_query_parsed("UPDATE $table_mailbox SET local_part = substring_index(username, '@', 1)");
+ db_query_parsed("ALTER TABLE $table_mailbox change local_part local_part varchar(255) NOT NULL"); // remove null-ness...
+ }
}
function upgrade_504_mysql() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|