diff options
author | zotlabs <mike@macgirvin.com> | 2018-02-22 20:52:39 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2018-02-22 20:52:39 -0800 |
commit | 277da4363194bd652918b100b93fdb0a85f9f689 (patch) | |
tree | 6504fe43d240ae65e32423b8ba2a81cd77967308 | |
parent | 80ce2def461705ebd0853e99ddfc0d1bc1de2915 (diff) | |
download | volse-hubzilla-277da4363194bd652918b100b93fdb0a85f9f689.tar.gz volse-hubzilla-277da4363194bd652918b100b93fdb0a85f9f689.tar.bz2 volse-hubzilla-277da4363194bd652918b100b93fdb0a85f9f689.zip |
provide DB compatibility for poll and voting implementations across several platforms
-rw-r--r-- | Zotlabs/Update/_1204.php | 34 | ||||
-rwxr-xr-x | boot.php | 2 | ||||
-rw-r--r-- | install/schema_mysql.sql | 6 | ||||
-rw-r--r-- | install/schema_postgres.sql | 6 |
4 files changed, 47 insertions, 1 deletions
diff --git a/Zotlabs/Update/_1204.php b/Zotlabs/Update/_1204.php new file mode 100644 index 000000000..f55526415 --- /dev/null +++ b/Zotlabs/Update/_1204.php @@ -0,0 +1,34 @@ +<?php + +namespace Zotlabs\Update; + +class _1204 { + + function run() { + + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $r1 = q("ALTER TABLE poll ADD pull_guid text NOT NULL"); + $r2 = q("create index \"poll_guid_idx\" on poll \"poll_guid\""); + $r3 = q("ALTER TABLE poll_elm ADD pelm_guid text NOT NULL"); + $r4 = q("create index \"pelm_guid_idx\" on poll_elm \"pelm_guid\""); + $r5 = q("ALTER TABLE vote ADD vote_guid text NOT NULL"); + $r6 = q("create index \"vote_guid_idx\" on vote \"vote_guid\""); + + $r = ($r1 && $r2 && $r3 && $r4 && $r5 && $r6); + } + else { + $r1 = q("ALTER TABLE `poll` ADD `pull_guid` VARCHAR(191) NOT NULL, ADD INDEX `poll_guid` (`pull_guid`) "); + $r2 = q("ALTER TABLE `poll_elm` ADD `pelm_guid` VARCHAR(191) NOT NULL, ADD INDEX `pelm_guid` (`pelm_guid`) "); + $r1 = q("ALTER TABLE `vote` ADD `vote_guid` VARCHAR(191) NOT NULL, ADD INDEX `vote_guid` (`vote_guid`) "); + + $r = ($r1 && $r2 && $r3); + } + + if($r) + return UPDATE_SUCCESS; + + return UPDATE_FAILED; + + } + +} @@ -53,7 +53,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' ); define ( 'STD_VERSION', '3.1.12' ); define ( 'ZOT_REVISION', '1.3' ); -define ( 'DB_UPDATE_VERSION', 1203 ); +define ( 'DB_UPDATE_VERSION', 1204 ); define ( 'PROJECT_BASE', __DIR__ ); diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index 36cd2539b..e1a63c1e3 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -964,11 +964,13 @@ CREATE TABLE IF NOT EXISTS `photo` ( CREATE TABLE IF NOT EXISTS `poll` ( `poll_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `poll_guid` varchar(191) NOT NULL, `poll_channel` int(10) unsigned NOT NULL DEFAULT 0 , `poll_desc` text NOT NULL, `poll_flags` int(11) NOT NULL DEFAULT 0 , `poll_votes` int(11) NOT NULL DEFAULT 0 , PRIMARY KEY (`poll_id`), + KEY `poll_guid` (`poll_guid`), KEY `poll_channel` (`poll_channel`), KEY `poll_flags` (`poll_flags`), KEY `poll_votes` (`poll_votes`) @@ -976,11 +978,13 @@ CREATE TABLE IF NOT EXISTS `poll` ( CREATE TABLE IF NOT EXISTS `poll_elm` ( `pelm_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `pelm_guid` varchar(191) NOT NULL, `pelm_poll` int(10) unsigned NOT NULL DEFAULT 0 , `pelm_desc` text NOT NULL, `pelm_flags` int(11) NOT NULL DEFAULT 0 , `pelm_result` float NOT NULL DEFAULT 0 , PRIMARY KEY (`pelm_id`), + KEY `pelm_guid` (`pelm_guid`), KEY `pelm_poll` (`pelm_poll`), KEY `pelm_result` (`pelm_result`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; @@ -1258,12 +1262,14 @@ CREATE TABLE IF NOT EXISTS `verify` ( CREATE TABLE IF NOT EXISTS `vote` ( `vote_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `vote_guid` varchar(191) NOT NULL, `vote_poll` int(11) NOT NULL DEFAULT 0 , `vote_element` int(11) NOT NULL DEFAULT 0 , `vote_result` text NOT NULL, `vote_xchan` char(191) NOT NULL DEFAULT '', PRIMARY KEY (`vote_id`), UNIQUE KEY `vote_vote` (`vote_poll`,`vote_element`,`vote_xchan`), + KEY `vote_guid` (`vote_guid`), KEY `vote_poll` (`vote_poll`), KEY `vote_element` (`vote_element`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index 082817a60..84b6a554a 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -942,6 +942,7 @@ create index "photo_os_storage" on photo ("os_storage"); CREATE TABLE "poll" ( "poll_id" serial NOT NULL, + "poll_guid" text NOT NULL, "poll_channel" bigint NOT NULL DEFAULT '0', "poll_desc" text NOT NULL, "poll_flags" bigint NOT NULL DEFAULT '0', @@ -949,17 +950,20 @@ CREATE TABLE "poll" ( PRIMARY KEY ("poll_id") ); +create index "poll_guid" on poll ("poll_guid"); create index "poll_channel" on poll ("poll_channel"); create index "poll_flags" on poll ("poll_flags"); create index "poll_votes" on poll ("poll_votes"); CREATE TABLE "poll_elm" ( "pelm_id" serial NOT NULL, + "pelm_guid" text NOT NULL, "pelm_poll" bigint NOT NULL DEFAULT '0', "pelm_desc" text NOT NULL, "pelm_flags" bigint NOT NULL DEFAULT '0', "pelm_result" float NOT NULL DEFAULT '0', PRIMARY KEY ("pelm_id") ); +create index "pelm_guid" on poll_elm ("pelm_guid"); create index "pelm_poll" on poll_elm ("pelm_poll"); create index "pelm_result" on poll_elm ("pelm_result"); @@ -1227,6 +1231,7 @@ create index "verify_meta" on verify ("meta"); create index "verify_created" on verify ("created"); CREATE TABLE "vote" ( "vote_id" serial NOT NULL, + "vote_guid" text NOT NULL, "vote_poll" bigint NOT NULL DEFAULT '0', "vote_element" bigint NOT NULL DEFAULT '0', "vote_result" text NOT NULL, @@ -1234,6 +1239,7 @@ CREATE TABLE "vote" ( PRIMARY KEY ("vote_id"), UNIQUE ("vote_poll","vote_element","vote_xchan") ); +create index "vote_guid" on vote ("vote_guid"); create index "vote_poll" on vote ("vote_poll"); create index "vote_element" on vote ("vote_element"); CREATE TABLE "xchan" ( |