From 525a37a284231e571f69bd37de772fb93793613b Mon Sep 17 00:00:00 2001 From: Jack Phoenix Date: Mon, 27 Jan 2020 04:58:11 +0200 Subject: [PATCH] PostgreSQL support Bug: T87542 Change-Id: I1089667c7228412fcb8f98702a8bad19abe76aa1 --- includes/AJAXPoll.class.php | 3 +++ sql/postgres/create-table--ajaxpoll_info.sql | 6 ++++++ sql/postgres/create-table--ajaxpoll_vote.sql | 15 +++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 sql/postgres/create-table--ajaxpoll_info.sql create mode 100644 sql/postgres/create-table--ajaxpoll_vote.sql 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);