fixes poll_question

This commit is contained in:
Jordie0608
2017-02-27 23:58:18 +11:00
parent 72a93bae7d
commit 97733d8dcf
4 changed files with 16 additions and 9 deletions

View File

@@ -118,13 +118,22 @@ ALTER TABLE `feedback`.`player`
, CHANGE COLUMN `ipTEMP` `ip` INT(10) UNSIGNED NOT NULL; , CHANGE COLUMN `ipTEMP` `ip` INT(10) UNSIGNED NOT NULL;
COMMIT; COMMIT;
START TRANSACTION;
ALTER TABLE `feedback`.`poll_question` ALTER TABLE `feedback`.`poll_question`
CHANGE COLUMN `polltype` `polltype` ENUM('OPTION', 'TEXT', 'NUMVAL', 'MULTICHOICE', 'IRV') NOT NULL CHANGE COLUMN `polltype` `polltype` ENUM('OPTION', 'TEXT', 'NUMVAL', 'MULTICHOICE', 'IRV') NOT NULL
, CHANGE COLUMN `adminonly` `adminonly` TINYINT(1) UNSIGNED NOT NULL , CHANGE COLUMN `adminonly` `adminonly` TINYINT(1) UNSIGNED NOT NULL
, CHANGE COLUMN `createdby_ckey` `createdby_ckey` VARCHAR(32) NULL DEFAULT NULL , CHANGE COLUMN `createdby_ckey` `createdby_ckey` VARCHAR(32) NULL DEFAULT NULL
, CHANGE COLUMN `createdby_ip` `createdby_ip` VARCHAR(32) NULL DEFAULT NULL , CHANGE COLUMN `dontshow` `dontshow` TINYINT(1) UNSIGNED NOT NULL
, CHANGE COLUMN `for_trialmin` `for_trialmin` VARCHAR(32) NULL DEFAULT NULL , ADD COLUMN `createdby_ipTEMP` INT UNSIGNED NOT NULL AFTER `createdby_ip`
, CHANGE COLUMN `dontshow` `dontshow` TINYINT(1) UNSIGNED NOT NULL; , DROP COLUMN `for_trialmin`;
SET SQL_SAFE_UPDATES = 0;
UPDATE `feedback`.`poll_question`
SET `createdby_ipTEMP` = COALESCE(NULLIF(INET_ATON(SUBSTRING_INDEX(`createdby_ip`, ':', 1)), ''), INET_ATON('0.0.0.0'));
SET SQL_SAFE_UPDATES = 1;
ALTER TABLE `feedback`.`poll_question`
DROP COLUMN `createdby_ip`
, CHANGE COLUMN `createdby_ipTEMP` `createdby_ip` INT(10) UNSIGNED NOT NULL;
COMMIT;
START TRANSACTION; START TRANSACTION;
ALTER TABLE `feedback`.`poll_textreply` ALTER TABLE `feedback`.`poll_textreply`

View File

@@ -308,8 +308,7 @@ CREATE TABLE `poll_question` (
`adminonly` tinyint(1) unsigned NOT NULL, `adminonly` tinyint(1) unsigned NOT NULL,
`multiplechoiceoptions` int(2) DEFAULT NULL, `multiplechoiceoptions` int(2) DEFAULT NULL,
`createdby_ckey` varchar(32) DEFAULT NULL, `createdby_ckey` varchar(32) DEFAULT NULL,
`createdby_ip` varchar(32) DEFAULT NULL, `createdby_ip` int(10) unsigned NOT NULL,
`for_trialmin` varchar(32) DEFAULT NULL,
`dontshow` tinyint(1) unsigned NOT NULL, `dontshow` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `idx_pquest_question_time_ckey` (`question`,`starttime`,`endtime`,`createdby_ckey`,`createdby_ip`), KEY `idx_pquest_question_time_ckey` (`question`,`starttime`,`endtime`,`createdby_ckey`,`createdby_ip`),

View File

@@ -308,8 +308,7 @@ CREATE TABLE `SS13_poll_question` (
`adminonly` tinyint(1) unsigned NOT NULL, `adminonly` tinyint(1) unsigned NOT NULL,
`multiplechoiceoptions` int(2) DEFAULT NULL, `multiplechoiceoptions` int(2) DEFAULT NULL,
`createdby_ckey` varchar(32) DEFAULT NULL, `createdby_ckey` varchar(32) DEFAULT NULL,
`createdby_ip` varchar(32) DEFAULT NULL, `createdby_ip` int(10) unsigned NOT NULL,
`for_trialmin` varchar(32) DEFAULT NULL,
`dontshow` tinyint(1) unsigned NOT NULL, `dontshow` tinyint(1) unsigned NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `idx_pquest_question_time_ckey` (`question`,`starttime`,`endtime`,`createdby_ckey`,`createdby_ip`), KEY `idx_pquest_question_time_ckey` (`question`,`starttime`,`endtime`,`createdby_ckey`,`createdby_ip`),

View File

@@ -98,7 +98,7 @@
if(!question) if(!question)
return return
question = sanitizeSQL(question) question = sanitizeSQL(question)
var/DBQuery/query_polladd_question = dbcon.NewQuery("INSERT INTO [format_table_name("poll_question")] (polltype, starttime, endtime, question, adminonly, multiplechoiceoptions, createdby_ckey, createdby_ip, dontshow) VALUES ('[polltype]', '[starttime]', '[endtime]', '[question]', '[adminonly]', '[choice_amount]', '[sql_ckey]', '[address]', '[dontshow]')") var/DBQuery/query_polladd_question = dbcon.NewQuery("INSERT INTO [format_table_name("poll_question")] (polltype, starttime, endtime, question, adminonly, multiplechoiceoptions, createdby_ckey, createdby_ip, dontshow) VALUES ('[polltype]', '[starttime]', '[endtime]', '[question]', '[adminonly]', '[choice_amount]', '[sql_ckey]', INET_ATON('[address]'), '[dontshow]')")
if(!query_polladd_question.Execute()) if(!query_polladd_question.Execute())
var/err = query_polladd_question.ErrorMsg() var/err = query_polladd_question.ErrorMsg()
log_game("SQL ERROR adding new poll question to table. Error : \[[err]\]\n") log_game("SQL ERROR adding new poll question to table. Error : \[[err]\]\n")
@@ -108,7 +108,7 @@
message_admins("[key_name_admin(usr)] has created a new server poll. Poll type: [polltype] - Admin Only: [adminonly ? "Yes" : "No"]<br>Question: [question]") message_admins("[key_name_admin(usr)] has created a new server poll. Poll type: [polltype] - Admin Only: [adminonly ? "Yes" : "No"]<br>Question: [question]")
return return
var/pollid = 0 var/pollid = 0
var/DBQuery/query_get_id = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_question")] WHERE question = '[question]' AND starttime = '[starttime]' AND endtime = '[endtime]' AND createdby_ckey = '[sql_ckey]' AND createdby_ip = '[address]'") var/DBQuery/query_get_id = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_question")] WHERE question = '[question]' AND starttime = '[starttime]' AND endtime = '[endtime]' AND createdby_ckey = '[sql_ckey]' AND createdby_ip = INET_ATON('[address]')")
if(!query_get_id.Execute()) if(!query_get_id.Execute())
var/err = query_get_id.ErrorMsg() var/err = query_get_id.ErrorMsg()
log_game("SQL ERROR obtaining id from poll_question table. Error : \[[err]\]\n") log_game("SQL ERROR obtaining id from poll_question table. Error : \[[err]\]\n")