function upgrade_438_pgsql() { # Table structure for table alias_domain $table_alias_domain = table_by_key('alias_domain'); $table_domain = table_by_key('domain'); if (_pgsql_object_exists($table_alias_domain)) { return; } db_query_parsed("\n CREATE TABLE {$table_alias_domain} (\n alias_domain character varying(255) NOT NULL REFERENCES {$table_domain}(domain) ON DELETE CASCADE,\n target_domain character varying(255) NOT NULL REFERENCES {$table_domain}(domain) ON DELETE CASCADE,\n created timestamp with time zone default now(),\n modified timestamp with time zone default now(),\n active boolean NOT NULL default true, \n PRIMARY KEY(alias_domain))"); db_query_parsed("CREATE INDEX alias_domain_active ON {$table_alias_domain}(alias_domain,active)"); db_query_parsed("COMMENT ON TABLE {$table_alias_domain} IS 'Postfix Admin - Domain Aliases'"); }
function upgrade_344_pgsql() { $fetchmail = table_by_key('fetchmail'); // a field name called 'date' is probably a bad idea. if (!_pgsql_object_exists('fetchmail')) { db_query_parsed("\n create table {$fetchmail}(\n id serial,\n mailbox varchar(255) not null default '',\n src_server varchar(255) not null default '',\n src_auth varchar(15) NOT NULL,\n src_user varchar(255) not null default '',\n src_password varchar(255) not null default '',\n src_folder varchar(255) not null default '',\n poll_time integer not null default 10,\n fetchall boolean not null default false,\n keep boolean not null default false,\n protocol varchar(15) NOT NULL,\n extra_options text,\n returned_text text,\n mda varchar(255) not null default '',\n date timestamp with time zone default now(),\n primary key(id),\n CHECK (src_auth IN ('password','kerberos_v5','kerberos','kerberos_v4','gssapi','cram-md5','otp','ntlm','msn','ssh','any')),\n CHECK (protocol IN ('POP3', 'IMAP', 'POP2', 'ETRN', 'AUTO'))\n );\n "); } // 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. } }