SF.net SVN: postfixadmin:[495] trunk/upgrade.php
Brought to you by:
christian_boltz,
gingerdog
|
From: <Gin...@us...> - 2008-12-11 21:15:04
|
Revision: 495
http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=495&view=rev
Author: GingerDog
Date: 2008-12-11 21:14:59 +0000 (Thu, 11 Dec 2008)
Log Message:
-----------
upgrade.php: first part of adding support for local_part of a mailboxs address - see https://sourceforge.net/forum/forum.php?thread_id=2343775&forum_id=676076
Modified Paths:
--------------
trunk/upgrade.php
Modified: trunk/upgrade.php
===================================================================
--- trunk/upgrade.php 2008-12-11 20:05:04 UTC (rev 494)
+++ trunk/upgrade.php 2008-12-11 21:14:59 UTC (rev 495)
@@ -41,7 +41,6 @@
AND pg_catalog.pg_table_is_visible(c.oid)
)
AND a.attname = '$field' ";
-// echo $sql;
$r = db_query($sql);
$row = db_row($r['result']);
if($row) {
@@ -1006,3 +1005,22 @@
db_query_parsed("ALTER TABLE $table_log CHANGE `data` `data` TEXT {LATIN1} NOT NULL");
}
+# Add a local_part field to the mailbox table, and populate it with the local part of the user's address.
+# This is to make it easier (hopefully) to change the filesystem location of a mailbox in the future
+# See https://sourceforge.net/forum/message.php?msg_id=5394663
+function upgrade_495_pgsql() {
+ $table_mailbox = table_by_key('mailbox');
+ if(!_pgsql_field_exists($table_mailbox, 'local_part')) {
+ db_query_parsed("ALTER TABLE $table_mailbox add column local_part varchar(255) ");
+ db_query_parsed("UPDATE $table_mailbox SET local_part = substring(username from '^(.*)@')");
+ db_query_parsed("ALTER TABLE $table_mailbox alter column local_part SET NOT NULL");
+ }
+}
+# 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) "); // 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...
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|