From 952c32df9f41d46ca85c821b605a851283fa0817 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 20 Sep 2018 17:31:46 -0400 Subject: mysql: Remove defaults from 'text' datatypes It is an error in Mysql for columns of type 'text' to have a default value. Removing these resolves Mysql errors and MariaDB warnings. --- schema.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'schema.sql') diff --git a/schema.sql b/schema.sql index 7587578..995b52d 100644 --- a/schema.sql +++ b/schema.sql @@ -181,7 +181,7 @@ CREATE TABLE issues ( numb int(32) NOT NULL, assignee varchar(8) NOT NULL DEFAULT '', seen int(1) NOT NULL DEFAULT 0, /* has the assignee seen this yet? */ - description text NOT NULL DEFAULT '', + description text NOT NULL, due varchar(64) NOT NULL DEFAULT '', tags varchar(64) NOT NULL DEFAULT '', @@ -195,7 +195,7 @@ DROP TABLE IF EXISTS mesgs; CREATE TABLE mesgs ( guid varchar(8) NOT NULL, author varchar(8) NOT NULL, - mesg text NOT NULL DEFAULT '', + mesg text NOT NULL, attachment varchar(64) NOT NULL DEFAULT '', PRIMARY KEY (guid) -- cgit v1.2.3 From c9f0bd92e76b63f8c6380211d309d76d5f4b8d8d Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 20 Sep 2018 17:42:51 -0400 Subject: mysql: Change issue.tags type to 'text' I don't mean to impose a character limit here, so I am changing this type to 'text'. As per the previous commit, the default value is also removed. --- schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'schema.sql') diff --git a/schema.sql b/schema.sql index 995b52d..32fc7ab 100644 --- a/schema.sql +++ b/schema.sql @@ -183,7 +183,7 @@ CREATE TABLE issues ( seen int(1) NOT NULL DEFAULT 0, /* has the assignee seen this yet? */ description text NOT NULL, due varchar(64) NOT NULL DEFAULT '', - tags varchar(64) NOT NULL DEFAULT '', + tags text NOT NULL, PRIMARY KEY (guid) ); -- cgit v1.2.3 From 86f7cbade863dc89934c5a44bc6683cc3826f8a9 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 20 Sep 2018 18:14:08 -0400 Subject: mysql: Add various default values I was experiencing problems on Mysql proper with the way Scrott interacts with the database when forming new objects. It attempts some writeback querries before all attributes are applied to the new objects. This makes sense if you understand how many initNew and helper functions are implemented. As a convenience a function which mutates an object will also apply its changes to the database automatically. These function are used instead of directly settings PHP object properties because there are additional pieces of logic performed to ensure everything remains valid in the datamodel. As was the case for a few types of objects, cirtain functions which behave this way were being called during an object's initNew(), causing DB writebacks to occur before some other 'default-less' field had been defined for that object. This patch provides some 'not so invalid' default states for database table columns which were previously undefined. This should also mitigate some issues I may have not run unto yet. --- schema.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'schema.sql') diff --git a/schema.sql b/schema.sql index 32fc7ab..13db8c7 100644 --- a/schema.sql +++ b/schema.sql @@ -94,7 +94,7 @@ CREATE TABLE objects ( guid varchar(8) NOT NULL, owner varchar(8) NOT NULL DEFAULT '', parent varchar(8) NOT NULL DEFAULT '', - name varchar(64) NOT NULL, + name varchar(64) NOT NULL DEFAULT '', created datetime NOT NULL, updated datetime NOT NULL, @@ -131,7 +131,7 @@ CREATE TABLE users ( salt varchar(64) NOT NULL, /* random SHA256 output, used as salt for auth */ alias varchar(64) NOT NULL DEFAULT '', email varchar(64) NOT NULL DEFAULT '', - emailVer varchar(8) NOT NULL, + emailVer varchar(8) NOT NULL DEFAULT '', admin int(1) NOT NULL DEFAULT 0, reg int(1) NOT NULL DEFAULT 0, /* if false, user doesn't have valid credentials */ emailConf int(1) NOT NULL DEFAULT 0, @@ -178,7 +178,7 @@ CREATE TABLE stages ( DROP TABLE IF EXISTS issues; CREATE TABLE issues ( guid varchar(8) NOT NULL, - numb int(32) NOT NULL, + numb int(32) NOT NULL DEFAULT 0, assignee varchar(8) NOT NULL DEFAULT '', seen int(1) NOT NULL DEFAULT 0, /* has the assignee seen this yet? */ description text NOT NULL, @@ -194,7 +194,7 @@ CREATE TABLE issues ( DROP TABLE IF EXISTS mesgs; CREATE TABLE mesgs ( guid varchar(8) NOT NULL, - author varchar(8) NOT NULL, + author varchar(8) NOT NULL DEFAULT '', mesg text NOT NULL, attachment varchar(64) NOT NULL DEFAULT '', -- cgit v1.2.3