diff --git a/includes/AJAXPoll.class.php b/includes/AJAXPoll.class.php index db2241c..2c13c02 100644 --- a/includes/AJAXPoll.class.php +++ b/includes/AJAXPoll.class.php @@ -597,6 +597,9 @@ During the last 48 hours, $tab2[0] votes have been given."; $db = $updater->getDB(); $patchPath = __DIR__ . '/../sql/'; + if ( $db->getType() == 'postgres' ) { + $patchPath .= 'postgres/'; + } if ( $db->tableExists( 'poll_info' ) ) { # poll_info.poll_title field was dropped in AJAXPoll version 1.72 diff --git a/sql/postgres/create-table--ajaxpoll_info.sql b/sql/postgres/create-table--ajaxpoll_info.sql new file mode 100644 index 0000000..678d684 --- /dev/null +++ b/sql/postgres/create-table--ajaxpoll_info.sql @@ -0,0 +1,6 @@ +CREATE TABLE IF NOT EXISTS ajaxpoll_info ( + poll_id TEXT NOT NULL PRIMARY KEY default '', + poll_txt TEXT, + poll_show_results_before_voting SMALLINT, + poll_date TIMESTAMPTZ default NULL +); diff --git a/sql/postgres/create-table--ajaxpoll_vote.sql b/sql/postgres/create-table--ajaxpoll_vote.sql new file mode 100644 index 0000000..322137d --- /dev/null +++ b/sql/postgres/create-table--ajaxpoll_vote.sql @@ -0,0 +1,15 @@ +DROP SEQUENCE IF EXISTS ajaxpoll_vote_poll_vote_id_seq CASCADE; +CREATE SEQUENCE ajaxpoll_vote_poll_vote_id_seq; + +CREATE TABLE IF NOT EXISTS ajaxpoll_vote ( + poll_vote_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('ajaxpoll_vote_poll_vote_id_seq'), + poll_id TEXT NOT NULL default '', + poll_actor INTEGER NOT NULL, + poll_ip TEXT default NULL, + poll_answer SMALLINT default NULL, + poll_date TIMESTAMPTZ default NULL +); + +ALTER SEQUENCE ajaxpoll_vote_poll_vote_id_seq OWNED BY ajaxpoll_vote.poll_vote_id; + +CREATE UNIQUE INDEX poll_id_actor ON ajaxpoll_vote (poll_id, poll_actor);