mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-20 03:36:20 +02:00
upgrade.php: reindent; fix postgresql fetchmail stuff
git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@352 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
parent
2814fd2ff7
commit
40417e9247
351
upgrade.php
351
upgrade.php
@ -320,8 +320,8 @@ function upgrade_1_mysql() {
|
||||
}
|
||||
|
||||
function upgrade_2_mysql() {
|
||||
# upgrade pre-2.1 database
|
||||
# from TABLE_BACKUP_MX.TXT
|
||||
# upgrade pre-2.1 database
|
||||
# from TABLE_BACKUP_MX.TXT
|
||||
$table_domain = table_by_key ('domain');
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN transport VARCHAR(255) AFTER maxquota;", TRUE);
|
||||
// don't think PGSQL supports 'AFTER transport'
|
||||
@ -469,7 +469,7 @@ function upgrade_3_mysql() {
|
||||
// these will not work on PostgreSQL; syntax is :
|
||||
// ALTER TABLE foo RENAME f1 TO f2
|
||||
$all_sql = split("\n", trim("
|
||||
ALTER TABLE $table_admin {RENAME_COLUMN} create_date created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;
|
||||
ALTER TABLE $table_admin {RENAME_COLUMN} create_date created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;
|
||||
ALTER TABLE $table_admin {RENAME_COLUMN} change_date modified DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;
|
||||
ALTER TABLE $table_alias {RENAME_COLUMN} create_date created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;
|
||||
ALTER TABLE $table_alias {RENAME_COLUMN} change_date modified DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL;
|
||||
@ -487,8 +487,8 @@ function upgrade_3_mysql() {
|
||||
ALTER TABLE $table_vacation ADD COLUMN created DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL AFTER domain;
|
||||
ALTER TABLE $table_vacation ADD COLUMN active TINYINT(1) DEFAULT '1' NOT NULL AFTER created;
|
||||
ALTER TABLE $table_vacation DROP PRIMARY KEY
|
||||
ALTER TABLE $table_vacation ADD PRIMARY KEY(email)
|
||||
UPDATE $table_vacation SET domain=SUBSTRING_INDEX(email, '@', -1) WHERE email=email;
|
||||
ALTER TABLE $table_vacation ADD PRIMARY KEY(email)
|
||||
UPDATE $table_vacation SET domain=SUBSTRING_INDEX(email, '@', -1) WHERE email=email;
|
||||
"));
|
||||
|
||||
foreach ($all_sql as $sql) {
|
||||
@ -539,56 +539,55 @@ function upgrade_4_pgsql() {
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain_admins ALTER COLUMN domain DROP DEFAULT");
|
||||
|
||||
$result = db_query_parsed("
|
||||
BEGIN;
|
||||
ALTER TABLE $table_log RENAME COLUMN data TO data_old;
|
||||
ALTER TABLE $table_log ADD COLUMN data text NOT NULL default '';
|
||||
UPDATE $table_log SET data = CAST(data_old AS text);
|
||||
ALTER TABLE $table_log DROP COLUMN data_old;
|
||||
COMMIT;");
|
||||
BEGIN;
|
||||
ALTER TABLE $table_log RENAME COLUMN data TO data_old;
|
||||
ALTER TABLE $table_log ADD COLUMN data text NOT NULL default '';
|
||||
UPDATE $table_log SET data = CAST(data_old AS text);
|
||||
ALTER TABLE $table_log DROP COLUMN data_old;
|
||||
COMMIT;");
|
||||
|
||||
$result = db_query_parsed("ALTER TABLE $table_mailbox ALTER COLUMN username DROP DEFAULT");
|
||||
$result = db_query_parsed("ALTER TABLE $table_mailbox ALTER COLUMN domain DROP DEFAULT");
|
||||
$result = db_query_parsed("ALTER TABLE $table_mailbox ALTER COLUMN username DROP DEFAULT");
|
||||
$result = db_query_parsed("ALTER TABLE $table_mailbox ALTER COLUMN domain DROP DEFAULT");
|
||||
|
||||
$result = db_query_parsed("
|
||||
BEGIN;
|
||||
ALTER TABLE $table_mailbox RENAME COLUMN domain TO domain_old;
|
||||
ALTER TABLE $table_mailbox ADD COLUMN domain varchar(255) REFERENCES domain (domain);
|
||||
UPDATE $table_mailbox SET domain = domain_old;
|
||||
ALTER TABLE $table_mailbox DROP COLUMN domain_old;
|
||||
COMMIT;"
|
||||
);
|
||||
if(!_pgsql_object_exists('mailbox_username_active')) {
|
||||
db_query_parsed('CREATE INDEX mailbox_username_active ON mailbox(username,active)');
|
||||
}
|
||||
|
||||
|
||||
$result = db_query_parsed("ALTER TABLE $table_vacation ALTER COLUMN body SET DEFAULT ''");
|
||||
if(_pgsql_field_exists($table_vacation, 'cache')) {
|
||||
$result = db_query_parsed("ALTER TABLE $table_vacation DROP COLUMN cache");
|
||||
}
|
||||
|
||||
$result = db_query_parsed("
|
||||
BEGIN;
|
||||
ALTER TABLE $table_vacation RENAME COLUMN domain to domain_old;
|
||||
ALTER TABLE $table_vacation ADD COLUMN domain varchar(255) REFERENCES domain;
|
||||
UPDATE $table_vacation SET domain = domain_old;
|
||||
ALTER TABLE $table_vacation DROP COLUMN domain_old;
|
||||
COMMIT;
|
||||
");
|
||||
|
||||
if(!_pgsql_object_exists('vacation_email_active')) {
|
||||
$result = db_query_parsed("CREATE INDEX vacation_email_active ON vacation(email,active)");
|
||||
}
|
||||
|
||||
if(!_pgsql_object_exists('vacation_notification')) {
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE vacation_notification (
|
||||
on_vacation character varying(255) NOT NULL REFERENCES vacation(email) ON DELETE CASCADE,
|
||||
notified character varying(255) NOT NULL,
|
||||
notified_at timestamp with time zone NOT NULL DEFAULT now(),
|
||||
CONSTRAINT vacation_notification_pkey primary key(on_vacation,notified)
|
||||
);");
|
||||
}
|
||||
BEGIN;
|
||||
ALTER TABLE $table_mailbox RENAME COLUMN domain TO domain_old;
|
||||
ALTER TABLE $table_mailbox ADD COLUMN domain varchar(255) REFERENCES domain (domain);
|
||||
UPDATE $table_mailbox SET domain = domain_old;
|
||||
ALTER TABLE $table_mailbox DROP COLUMN domain_old;
|
||||
COMMIT;"
|
||||
);
|
||||
if(!_pgsql_object_exists('mailbox_username_active')) {
|
||||
db_query_parsed('CREATE INDEX mailbox_username_active ON mailbox(username,active)');
|
||||
}
|
||||
|
||||
|
||||
$result = db_query_parsed("ALTER TABLE $table_vacation ALTER COLUMN body SET DEFAULT ''");
|
||||
if(_pgsql_field_exists($table_vacation, 'cache')) {
|
||||
$result = db_query_parsed("ALTER TABLE $table_vacation DROP COLUMN cache");
|
||||
}
|
||||
|
||||
$result = db_query_parsed("
|
||||
BEGIN;
|
||||
ALTER TABLE $table_vacation RENAME COLUMN domain to domain_old;
|
||||
ALTER TABLE $table_vacation ADD COLUMN domain varchar(255) REFERENCES domain;
|
||||
UPDATE $table_vacation SET domain = domain_old;
|
||||
ALTER TABLE $table_vacation DROP COLUMN domain_old;
|
||||
COMMIT;
|
||||
");
|
||||
|
||||
if(!_pgsql_object_exists('vacation_email_active')) {
|
||||
$result = db_query_parsed("CREATE INDEX vacation_email_active ON vacation(email,active)");
|
||||
}
|
||||
|
||||
if(!_pgsql_object_exists('vacation_notification')) {
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE vacation_notification (
|
||||
on_vacation character varying(255) NOT NULL REFERENCES vacation(email) ON DELETE CASCADE,
|
||||
notified character varying(255) NOT NULL,
|
||||
notified_at timestamp with time zone NOT NULL DEFAULT now(),
|
||||
CONSTRAINT vacation_notification_pkey primary key(on_vacation,notified));");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -616,90 +615,89 @@ function upgrade_5_mysql() {
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`username`),
|
||||
KEY username (`username`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Admins';
|
||||
");
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Admins'; ");
|
||||
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('alias') . "` (
|
||||
`address` varchar(255) NOT NULL default '',
|
||||
`goto` text NOT NULL,
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`address`),
|
||||
KEY address (`address`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Aliases';
|
||||
");
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('alias') . "` (
|
||||
`address` varchar(255) NOT NULL default '',
|
||||
`goto` text NOT NULL,
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`address`),
|
||||
KEY address (`address`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Aliases';
|
||||
");
|
||||
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('domain') . "` (
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`description` varchar(255) NOT NULL default '',
|
||||
`aliases` int(10) NOT NULL default '0',
|
||||
`mailboxes` int(10) NOT NULL default '0',
|
||||
`maxquota` int(10) NOT NULL default '0',
|
||||
`quota` int(10) NOT NULL default '0',
|
||||
`transport` varchar(255) default NULL,
|
||||
`backupmx` tinyint(1) NOT NULL default '0',
|
||||
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`domain`),
|
||||
KEY domain (`domain`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Domains';
|
||||
");
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('domain') . "` (
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`description` varchar(255) NOT NULL default '',
|
||||
`aliases` int(10) NOT NULL default '0',
|
||||
`mailboxes` int(10) NOT NULL default '0',
|
||||
`maxquota` int(10) NOT NULL default '0',
|
||||
`quota` int(10) NOT NULL default '0',
|
||||
`transport` varchar(255) default NULL,
|
||||
`backupmx` tinyint(1) NOT NULL default '0',
|
||||
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`domain`),
|
||||
KEY domain (`domain`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Domains';
|
||||
");
|
||||
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('domain_admins') . "` (
|
||||
`username` varchar(255) NOT NULL default '',
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
KEY username (`username`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Domain Admins';
|
||||
");
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('domain_admins') . "` (
|
||||
`username` varchar(255) NOT NULL default '',
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
KEY username (`username`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Domain Admins';
|
||||
");
|
||||
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('log') . "` (
|
||||
`timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`username` varchar(255) NOT NULL default '',
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`action` varchar(255) NOT NULL default '',
|
||||
`data` varchar(255) NOT NULL default '',
|
||||
KEY timestamp (`timestamp`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Log';
|
||||
");
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('log') . "` (
|
||||
`timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`username` varchar(255) NOT NULL default '',
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`action` varchar(255) NOT NULL default '',
|
||||
`data` varchar(255) NOT NULL default '',
|
||||
KEY timestamp (`timestamp`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Log';
|
||||
");
|
||||
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('mailbox') . "` (
|
||||
`username` varchar(255) NOT NULL default '',
|
||||
`password` varchar(255) NOT NULL default '',
|
||||
`name` varchar(255) NOT NULL default '',
|
||||
`maildir` varchar(255) NOT NULL default '',
|
||||
`quota` int(10) NOT NULL default '0',
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`username`),
|
||||
KEY username (`username`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Mailboxes';
|
||||
");
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('mailbox') . "` (
|
||||
`username` varchar(255) NOT NULL default '',
|
||||
`password` varchar(255) NOT NULL default '',
|
||||
`name` varchar(255) NOT NULL default '',
|
||||
`maildir` varchar(255) NOT NULL default '',
|
||||
`quota` int(10) NOT NULL default '0',
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`username`),
|
||||
KEY username (`username`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Mailboxes';
|
||||
");
|
||||
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('vacation') . "` (
|
||||
`email` varchar(255) NOT NULL default '',
|
||||
`subject` varchar(255) NOT NULL default '',
|
||||
`body` text NOT NULL default '',
|
||||
`cache` text NOT NULL default '',
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`email`),
|
||||
KEY email (`email`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Vacation';
|
||||
");
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} `" . table_by_key('vacation') . "` (
|
||||
`email` varchar(255) NOT NULL default '',
|
||||
`subject` varchar(255) NOT NULL default '',
|
||||
`body` text NOT NULL default '',
|
||||
`cache` text NOT NULL default '',
|
||||
`domain` varchar(255) NOT NULL default '',
|
||||
`created` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`active` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`email`),
|
||||
KEY email (`email`)
|
||||
) TYPE=MyISAM DEFAULT {LATIN1} COMMENT='Postfix Admin - Virtual Vacation';
|
||||
");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -724,7 +722,7 @@ function upgrade_81_mysql() { # MySQL only
|
||||
ALTER TABLE `$table_vacation` CHANGE `domain` `domain` VARCHAR( 255 ) {LATIN1} NOT NULL
|
||||
ALTER TABLE `$table_vacation` CHANGE `active` `active` TINYINT( 1 ) NOT NULL DEFAULT '1'
|
||||
ALTER TABLE `$table_vacation` DEFAULT {LATIN1}
|
||||
ALTER TABLE `$table_vacation` ENGINE = INNODB
|
||||
ALTER TABLE `$table_vacation` ENGINE = INNODB
|
||||
"));
|
||||
|
||||
foreach ($all_sql as $sql) {
|
||||
@ -771,34 +769,33 @@ function upgrade_318_mysql() {
|
||||
notified varchar(255) NOT NULL,
|
||||
notified_at timestamp NOT NULL default CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY on_vacation (`on_vacation`, `notified`),
|
||||
CONSTRAINT `vacation_notification_pkey`
|
||||
FOREIGN KEY (`on_vacation`) REFERENCES vacation(`email`) ON DELETE CASCADE
|
||||
)
|
||||
ENGINE=InnoDB DEFAULT {LATIN1} TYPE=InnoDB
|
||||
COMMENT='Postfix Admin - Virtual Vacation Notifications'
|
||||
");
|
||||
|
||||
# in case someone has manually created the table with utf8 fields before:
|
||||
$all_sql = split("\n", trim("
|
||||
ALTER TABLE `$table_vacation_notification` DROP FOREIGN KEY `vacation_notification_pkey`
|
||||
ALTER TABLE `$table_vacation_notification` CHANGE `on_vacation` `on_vacation` VARCHAR( 255 ) {LATIN1} NOT NULL
|
||||
ALTER TABLE `$table_vacation_notification` CHANGE `notified` `notified` VARCHAR( 255 ) {LATIN1} NOT NULL
|
||||
ALTER TABLE `$table_vacation_notification` DEFAULT {LATIN1}
|
||||
"));
|
||||
# Possible errors that can be ignored:
|
||||
# None.
|
||||
# If something goes wrong, the user should drop the vacation_notification table
|
||||
# (not a great loss) and re-create it using this function.
|
||||
|
||||
foreach ($all_sql as $sql) {
|
||||
$result = db_query_parsed($sql);
|
||||
}
|
||||
|
||||
# create constraint...
|
||||
$result = db_query_parsed("
|
||||
ALTER TABLE $table_vacation_notification ADD CONSTRAINT `vacation_notification_pkey`
|
||||
FOREIGN KEY (`on_vacation`) REFERENCES vacation(`email`) ON DELETE CASCADE
|
||||
CONSTRAINT `vacation_notification_pkey`
|
||||
FOREIGN KEY (`on_vacation`) REFERENCES vacation(`email`) ON DELETE CASCADE
|
||||
)
|
||||
ENGINE=InnoDB DEFAULT {LATIN1} TYPE=InnoDB
|
||||
COMMENT='Postfix Admin - Virtual Vacation Notifications'
|
||||
");
|
||||
|
||||
# in case someone has manually created the table with utf8 fields before:
|
||||
$all_sql = split("\n", trim("
|
||||
ALTER TABLE `$table_vacation_notification` DROP FOREIGN KEY `vacation_notification_pkey`
|
||||
ALTER TABLE `$table_vacation_notification` CHANGE `on_vacation` `on_vacation` VARCHAR( 255 ) {LATIN1} NOT NULL
|
||||
ALTER TABLE `$table_vacation_notification` CHANGE `notified` `notified` VARCHAR( 255 ) {LATIN1} NOT NULL
|
||||
ALTER TABLE `$table_vacation_notification` DEFAULT {LATIN1}
|
||||
"));
|
||||
# Possible errors that can be ignored:
|
||||
# None.
|
||||
# If something goes wrong, the user should drop the vacation_notification table
|
||||
# (not a great loss) and re-create it using this function.
|
||||
|
||||
foreach ($all_sql as $sql) {
|
||||
$result = db_query_parsed($sql);
|
||||
}
|
||||
|
||||
# create constraint...
|
||||
$result = db_query_parsed("
|
||||
ALTER TABLE $table_vacation_notification ADD CONSTRAINT `vacation_notification_pkey`
|
||||
FOREIGN KEY (`on_vacation`) REFERENCES vacation(`email`) ON DELETE CASCADE ");
|
||||
}
|
||||
|
||||
|
||||
@ -807,10 +804,10 @@ $result = db_query_parsed("
|
||||
*/
|
||||
function upgrade_344_mysql() {
|
||||
|
||||
$table_vacation_notification = table_by_key('vacation_notification');
|
||||
$table_fetchmail = table_by_key('fetchmail');
|
||||
|
||||
db_query_parsed( "
|
||||
create table fetchmail(
|
||||
create table $table_fetchmail(
|
||||
id int(11) unsigned not null auto_increment,
|
||||
mailbox varchar(255) not null default '',
|
||||
src_server varchar(255) not null default '',
|
||||
@ -832,6 +829,38 @@ function upgrade_344_mysql() {
|
||||
}
|
||||
|
||||
function upgrade_344_pgsql() {
|
||||
# TODO: create fetchmail table for PgSQL
|
||||
$fetchmail = table_by_key('fetchmail');
|
||||
// a field name called 'date' is probably a bad idea.
|
||||
if(!_pgsql_object_exists('fetchmail')) {
|
||||
db_query_parsed( "
|
||||
create table $fetchmail(
|
||||
id serial,
|
||||
mailbox varchar(255) not null default '',
|
||||
src_server varchar(255) not null default '',
|
||||
src_auth varchar(15) NOT NULL,
|
||||
src_user varchar(255) not null default '',
|
||||
src_password varchar(255) not null default '',
|
||||
src_folder varchar(255) not null default '',
|
||||
poll_time integer not null default 10,
|
||||
fetchall boolean not null default false,
|
||||
keep boolean not null default false,
|
||||
protocol varchar(15) NOT NULL,
|
||||
extra_options text,
|
||||
returned_text text,
|
||||
mda varchar(255) not null default '',
|
||||
date timestamp with time zone default now(),
|
||||
primary key(id),
|
||||
CHECK (src_auth IN ('password','kerberos_v5','kerberos','kerberos_v4','gssapi','cram-md5','otp','ntlm','msn','ssh','any')),
|
||||
CHECK (protocol IN ('POP3', 'IMAP', 'POP2', 'ETRN', 'AUTO'))
|
||||
);
|
||||
");
|
||||
}
|
||||
// MySQL expects sequences to start at 1. Stupid database.
|
||||
// fetchmail.php requires id parameters to be > 0, as it does if($id) like logic... hence if we don't
|
||||
// fudge the sequence starting point, you cannot delete/edit the first entry if using PostgreSQL.
|
||||
// I'm sure there's a more elegant way of fixing it properly.... but this should work for now.
|
||||
if(_pgsql_object_exists('fetchmail_id_seq')) {
|
||||
db_query_parsed("SELECT nextval('{$fetchmail}_id_seq')"); // I don't care about number waste.
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user