2017-10-16 07:32:58 +00:00
package main
2018-10-27 03:21:02 +00:00
import "github.com/Azareal/Gosora/query_gen"
2017-10-16 07:32:58 +00:00
2018-12-27 05:42:41 +00:00
var mysqlPre = "utf8mb4"
var mysqlCol = "utf8mb4_general_ci"
type tblColumn = qgen . DBTableColumn
type tblKey = qgen . DBTableKey
2017-11-12 05:25:04 +00:00
func createTables ( adapter qgen . Adapter ) error {
2018-12-27 05:42:41 +00:00
qgen . Install . CreateTable ( "users" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "uid" , "int" , 0 , false , true , "" } ,
tblColumn { "name" , "varchar" , 100 , false , false , "" } ,
tblColumn { "password" , "varchar" , 100 , false , false , "" } ,
tblColumn { "salt" , "varchar" , 80 , false , false , "''" } ,
tblColumn { "group" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "active" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "is_super_admin" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "createdAt" , "createdAt" , 0 , false , false , "" } ,
tblColumn { "lastActiveAt" , "datetime" , 0 , false , false , "" } ,
tblColumn { "session" , "varchar" , 200 , false , false , "''" } ,
//tblColumn{"authToken", "varchar", 200, false, false, "''"},
tblColumn { "last_ip" , "varchar" , 200 , false , false , "0.0.0.0.0" } ,
tblColumn { "email" , "varchar" , 200 , false , false , "''" } ,
tblColumn { "avatar" , "varchar" , 100 , false , false , "''" } ,
tblColumn { "message" , "text" , 0 , false , false , "''" } ,
tblColumn { "url_prefix" , "varchar" , 20 , false , false , "''" } ,
tblColumn { "url_name" , "varchar" , 100 , false , false , "''" } ,
tblColumn { "level" , "smallint" , 0 , false , false , "0" } ,
tblColumn { "score" , "int" , 0 , false , false , "0" } ,
tblColumn { "posts" , "int" , 0 , false , false , "0" } ,
tblColumn { "bigposts" , "int" , 0 , false , false , "0" } ,
tblColumn { "megaposts" , "int" , 0 , false , false , "0" } ,
tblColumn { "topics" , "int" , 0 , false , false , "0" } ,
tblColumn { "liked" , "int" , 0 , false , false , "0" } ,
2018-03-31 05:25:27 +00:00
// These two are to bound liked queries with little bits of information we know about the user to reduce the server load
2018-12-27 05:42:41 +00:00
tblColumn { "oldestItemLikedCreatedAt" , "datetime" , 0 , false , false , "" } , // For internal use only, semantics may change
tblColumn { "lastLiked" , "datetime" , 0 , false , false , "" } , // For internal use only, semantics may change
2018-03-31 05:25:27 +00:00
2018-12-27 05:42:41 +00:00
//tblColumn{"penalty_count","int",0,false,false,"0"},
tblColumn { "temp_group" , "int" , 0 , false , false , "0" } , // For temporary groups, set this to zero when a temporary group isn't in effect
2017-11-12 05:25:04 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "uid" , "primary" } ,
tblKey { "name" , "unique" } ,
2017-10-16 07:32:58 +00:00
} ,
)
2018-12-27 05:42:41 +00:00
qgen . Install . CreateTable ( "users_groups" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "gid" , "int" , 0 , false , true , "" } ,
tblColumn { "name" , "varchar" , 100 , false , false , "" } ,
tblColumn { "permissions" , "text" , 0 , false , false , "" } ,
tblColumn { "plugin_perms" , "text" , 0 , false , false , "" } ,
tblColumn { "is_mod" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "is_admin" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "is_banned" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "user_count" , "int" , 0 , false , false , "0" } , // TODO: Implement this
2017-11-12 05:25:04 +00:00
2018-12-27 05:42:41 +00:00
tblColumn { "tag" , "varchar" , 50 , false , false , "''" } ,
2017-11-12 05:25:04 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "gid" , "primary" } ,
2017-10-16 07:32:58 +00:00
} ,
)
2018-12-27 05:42:41 +00:00
qgen . Install . CreateTable ( "users_2fa_keys" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "uid" , "int" , 0 , false , false , "" } ,
tblColumn { "secret" , "varchar" , 100 , false , false , "" } ,
tblColumn { "scratch1" , "varchar" , 50 , false , false , "" } ,
tblColumn { "scratch2" , "varchar" , 50 , false , false , "" } ,
tblColumn { "scratch3" , "varchar" , 50 , false , false , "" } ,
tblColumn { "scratch4" , "varchar" , 50 , false , false , "" } ,
tblColumn { "scratch5" , "varchar" , 50 , false , false , "" } ,
tblColumn { "scratch6" , "varchar" , 50 , false , false , "" } ,
tblColumn { "scratch7" , "varchar" , 50 , false , false , "" } ,
tblColumn { "scratch8" , "varchar" , 50 , false , false , "" } ,
tblColumn { "createdAt" , "createdAt" , 0 , false , false , "" } ,
2018-06-17 07:28:18 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "uid" , "primary" } ,
2018-06-17 07:28:18 +00:00
} ,
)
2018-06-06 00:21:22 +00:00
2017-10-16 07:32:58 +00:00
// What should we do about global penalties? Put them on the users table for speed? Or keep them here?
// Should we add IP Penalties? No, that's a stupid idea, just implement IP Bans properly. What about shadowbans?
// TODO: Perm overrides
// TODO: Add a mod-queue and other basic auto-mod features. This is needed for awaiting activation and the mod_queue penalty flag
2017-11-02 04:12:51 +00:00
// TODO: Add a penalty type where a user is stopped from creating plugin_guilds social groups
2017-10-16 07:32:58 +00:00
// TODO: Shadow bans. We will probably have a CanShadowBan permission for this, as we *really* don't want people using this lightly.
/ * qgen . Install . CreateTable ( "users_penalties" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "uid" , "int" , 0 , false , false , "" } ,
tblColumn { "element_id" , "int" , 0 , false , false , "" } ,
tblColumn { "element_type" , "varchar" , 50 , false , false , "" } , //forum, profile?, and social_group. Leave blank for global.
tblColumn { "overrides" , "text" , 0 , false , false , "{}" } ,
2017-10-16 07:32:58 +00:00
2018-12-27 05:42:41 +00:00
tblColumn { "mod_queue" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "shadow_ban" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "no_avatar" , "boolean" , 0 , false , false , "0" } , // Coming Soon. Should this be a perm override instead?
2017-10-16 07:32:58 +00:00
// Do we *really* need rate-limit penalty types? Are we going to be allowing bots or something?
2018-12-27 05:42:41 +00:00
//tblColumn{"posts_per_hour","int",0,false,false,"0"},
//tblColumn{"topics_per_hour","int",0,false,false,"0"},
//tblColumn{"posts_count","int",0,false,false,"0"},
//tblColumn{"topic_count","int",0,false,false,"0"},
//tblColumn{"last_hour","int",0,false,false,"0"}, // UNIX Time, as we don't need to do anything too fancy here. When an hour has elapsed since that time, reset the hourly penalty counters.
2017-10-16 07:32:58 +00:00
2018-12-27 05:42:41 +00:00
tblColumn { "issued_by" , "int" , 0 , false , false , "" } ,
tblColumn { "issued_at" , "createdAt" , 0 , false , false , "" } ,
tblColumn { "expires_at" , "datetime" , 0 , false , false , "" } ,
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2017-10-16 07:32:58 +00:00
) * /
qgen . Install . CreateTable ( "users_groups_scheduler" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "uid" , "int" , 0 , false , false , "" } ,
tblColumn { "set_group" , "int" , 0 , false , false , "" } ,
2017-10-16 07:32:58 +00:00
2018-12-27 05:42:41 +00:00
tblColumn { "issued_by" , "int" , 0 , false , false , "" } ,
tblColumn { "issued_at" , "createdAt" , 0 , false , false , "" } ,
tblColumn { "revert_at" , "datetime" , 0 , false , false , "" } ,
tblColumn { "temporary" , "boolean" , 0 , false , false , "" } , // special case for permanent bans to do the necessary bookkeeping, might be removed in the future
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "uid" , "primary" } ,
2017-10-16 07:32:58 +00:00
} ,
)
2018-07-28 12:52:23 +00:00
// TODO: Can we use a piece of software dedicated to persistent queues for this rather than relying on the database for it?
qgen . Install . CreateTable ( "users_avatar_queue" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "uid" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
2018-07-28 12:52:23 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "uid" , "primary" } ,
2018-07-28 12:52:23 +00:00
} ,
)
// TODO: Should we add a users prefix to this table to fit the "unofficial convention"?
2017-10-16 07:32:58 +00:00
qgen . Install . CreateTable ( "emails" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "email" , "varchar" , 200 , false , false , "" } ,
tblColumn { "uid" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "validated" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "token" , "varchar" , 200 , false , false , "''" } ,
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2017-10-16 07:32:58 +00:00
)
2018-07-05 09:54:01 +00:00
// TODO: Allow for patterns in domains, if the bots try to shake things up there?
/ *
qgen . Install . CreateTable ( "email_domain_blacklist" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "domain" , "varchar" , 200 , false , false , "" } ,
tblColumn { "gtld" , "boolean" , 0 , false , false , "0" } ,
2018-07-05 09:54:01 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "domain" , "primary" } ,
2018-07-05 09:54:01 +00:00
} ,
)
* /
2018-12-27 05:42:41 +00:00
qgen . Install . CreateTable ( "forums" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "fid" , "int" , 0 , false , true , "" } ,
tblColumn { "name" , "varchar" , 100 , false , false , "" } ,
tblColumn { "desc" , "varchar" , 200 , false , false , "" } ,
tblColumn { "active" , "boolean" , 0 , false , false , "1" } ,
tblColumn { "topicCount" , "int" , 0 , false , false , "0" } ,
tblColumn { "preset" , "varchar" , 100 , false , false , "''" } ,
tblColumn { "parentID" , "int" , 0 , false , false , "0" } ,
tblColumn { "parentType" , "varchar" , 50 , false , false , "''" } ,
tblColumn { "lastTopicID" , "int" , 0 , false , false , "0" } ,
tblColumn { "lastReplyerID" , "int" , 0 , false , false , "0" } ,
2017-11-12 05:25:04 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "fid" , "primary" } ,
2017-10-16 07:32:58 +00:00
} ,
)
qgen . Install . CreateTable ( "forums_permissions" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "fid" , "int" , 0 , false , false , "" } ,
tblColumn { "gid" , "int" , 0 , false , false , "" } ,
tblColumn { "preset" , "varchar" , 100 , false , false , "''" } ,
tblColumn { "permissions" , "text" , 0 , false , false , "" } ,
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
2017-10-16 07:32:58 +00:00
// TODO: Test to see that the compound primary key works
2018-12-27 05:42:41 +00:00
tblKey { "fid,gid" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "topics" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "tid" , "int" , 0 , false , true , "" } ,
tblColumn { "title" , "varchar" , 100 , false , false , "" } , // TODO: Increase the max length to 200?
tblColumn { "content" , "text" , 0 , false , false , "" } ,
tblColumn { "parsed_content" , "text" , 0 , false , false , "" } ,
tblColumn { "createdAt" , "createdAt" , 0 , false , false , "" } ,
tblColumn { "lastReplyAt" , "datetime" , 0 , false , false , "" } ,
tblColumn { "lastReplyBy" , "int" , 0 , false , false , "" } ,
tblColumn { "createdBy" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "is_closed" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "sticky" , "boolean" , 0 , false , false , "0" } ,
2018-10-06 13:14:11 +00:00
// TODO: Add an index for this
2018-12-27 05:42:41 +00:00
tblColumn { "parentID" , "int" , 0 , false , false , "2" } ,
tblColumn { "ipaddress" , "varchar" , 200 , false , false , "0.0.0.0.0" } ,
tblColumn { "postCount" , "int" , 0 , false , false , "1" } ,
tblColumn { "likeCount" , "int" , 0 , false , false , "0" } ,
//tblColumn{"attachCount","int",0,false,false,"0"},
tblColumn { "words" , "int" , 0 , false , false , "0" } ,
tblColumn { "views" , "int" , 0 , false , false , "0" } ,
//tblColumn{"dailyViews", "int", 0, false, false, "0"},
//tblColumn{"weeklyViews", "int", 0, false, false, "0"},
//tblColumn{"monthlyViews", "int", 0, false, false, "0"},
2018-10-06 13:14:11 +00:00
// ? - A little hacky, maybe we could do something less likely to bite us with huge numbers of topics?
// TODO: Add an index for this?
2018-12-27 05:42:41 +00:00
//tblColumn{"lastMonth", "datetime", 0, false, false, ""},
tblColumn { "css_class" , "varchar" , 100 , false , false , "''" } ,
tblColumn { "poll" , "int" , 0 , false , false , "0" } ,
tblColumn { "data" , "varchar" , 200 , false , false , "''" } ,
} ,
[ ] tblKey {
tblKey { "tid" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "replies" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "rid" , "int" , 0 , false , true , "" } , // TODO: Rename to replyID?
tblColumn { "tid" , "int" , 0 , false , false , "" } , // TODO: Rename to topicID?
tblColumn { "content" , "text" , 0 , false , false , "" } ,
tblColumn { "parsed_content" , "text" , 0 , false , false , "" } ,
tblColumn { "createdAt" , "createdAt" , 0 , false , false , "" } ,
tblColumn { "createdBy" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "lastEdit" , "int" , 0 , false , false , "0" } ,
tblColumn { "lastEditBy" , "int" , 0 , false , false , "0" } ,
tblColumn { "lastUpdated" , "datetime" , 0 , false , false , "" } ,
tblColumn { "ipaddress" , "varchar" , 200 , false , false , "0.0.0.0.0" } ,
tblColumn { "likeCount" , "int" , 0 , false , false , "0" } ,
tblColumn { "words" , "int" , 0 , false , false , "1" } , // ? - replies has a default of 1 and topics has 0? why?
tblColumn { "actionType" , "varchar" , 20 , false , false , "''" } ,
tblColumn { "poll" , "int" , 0 , false , false , "0" } ,
} ,
[ ] tblKey {
tblKey { "rid" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "attachments" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "attachID" , "int" , 0 , false , true , "" } ,
tblColumn { "sectionID" , "int" , 0 , false , false , "0" } ,
tblColumn { "sectionTable" , "varchar" , 200 , false , false , "forums" } ,
tblColumn { "originID" , "int" , 0 , false , false , "" } ,
tblColumn { "originTable" , "varchar" , 200 , false , false , "replies" } ,
tblColumn { "uploadedBy" , "int" , 0 , false , false , "" } , // TODO; Make this a foreign key
tblColumn { "path" , "varchar" , 200 , false , false , "" } ,
} ,
[ ] tblKey {
tblKey { "attachID" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "revisions" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "reviseID" , "int" , 0 , false , true , "" } ,
tblColumn { "content" , "text" , 0 , false , false , "" } ,
tblColumn { "contentID" , "int" , 0 , false , false , "" } ,
tblColumn { "contentType" , "varchar" , 100 , false , false , "replies" } ,
tblColumn { "createdAt" , "createdAt" , 0 , false , false , "" } ,
2018-03-31 05:25:27 +00:00
// TODO: Add a createdBy column?
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "reviseID" , "primary" } ,
2018-02-10 15:07:21 +00:00
} ,
2017-10-16 07:32:58 +00:00
)
2018-12-27 05:42:41 +00:00
qgen . Install . CreateTable ( "polls" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "pollID" , "int" , 0 , false , true , "" } ,
tblColumn { "parentID" , "int" , 0 , false , false , "0" } ,
tblColumn { "parentTable" , "varchar" , 100 , false , false , "topics" } , // topics, replies
tblColumn { "type" , "int" , 0 , false , false , "0" } ,
tblColumn { "options" , "json" , 0 , false , false , "" } ,
tblColumn { "votes" , "int" , 0 , false , false , "0" } ,
2018-01-25 04:57:33 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "pollID" , "primary" } ,
2018-01-25 04:57:33 +00:00
} ,
)
2018-01-28 14:30:24 +00:00
qgen . Install . CreateTable ( "polls_options" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "pollID" , "int" , 0 , false , false , "" } ,
tblColumn { "option" , "int" , 0 , false , false , "0" } ,
tblColumn { "votes" , "int" , 0 , false , false , "0" } ,
2018-01-28 14:30:24 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2018-01-28 14:30:24 +00:00
)
2018-12-27 05:42:41 +00:00
qgen . Install . CreateTable ( "polls_votes" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "pollID" , "int" , 0 , false , false , "" } ,
tblColumn { "uid" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "option" , "int" , 0 , false , false , "0" } ,
tblColumn { "castAt" , "createdAt" , 0 , false , false , "" } ,
tblColumn { "ipaddress" , "varchar" , 200 , false , false , "0.0.0.0.0" } ,
2018-01-25 04:57:33 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2018-01-25 04:57:33 +00:00
)
2018-12-27 05:42:41 +00:00
qgen . Install . CreateTable ( "users_replies" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "rid" , "int" , 0 , false , true , "" } ,
tblColumn { "uid" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "content" , "text" , 0 , false , false , "" } ,
tblColumn { "parsed_content" , "text" , 0 , false , false , "" } ,
tblColumn { "createdAt" , "createdAt" , 0 , false , false , "" } ,
tblColumn { "createdBy" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "lastEdit" , "int" , 0 , false , false , "0" } ,
tblColumn { "lastEditBy" , "int" , 0 , false , false , "0" } ,
tblColumn { "ipaddress" , "varchar" , 200 , false , false , "0.0.0.0.0" } ,
2017-11-12 05:25:04 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "rid" , "primary" } ,
2017-10-16 07:32:58 +00:00
} ,
)
qgen . Install . CreateTable ( "likes" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "weight" , "tinyint" , 0 , false , false , "1" } ,
tblColumn { "targetItem" , "int" , 0 , false , false , "" } ,
tblColumn { "targetType" , "varchar" , 50 , false , false , "replies" } ,
tblColumn { "sentBy" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "createdAt" , "createdAt" , 0 , false , false , "" } ,
tblColumn { "recalc" , "tinyint" , 0 , false , false , "0" } ,
2017-11-12 05:25:04 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2017-10-16 07:32:58 +00:00
)
qgen . Install . CreateTable ( "activity_stream_matches" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "watcher" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "asid" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2017-10-16 07:32:58 +00:00
)
qgen . Install . CreateTable ( "activity_stream" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "asid" , "int" , 0 , false , true , "" } ,
tblColumn { "actor" , "int" , 0 , false , false , "" } , /* the one doing the act */ // TODO: Make this a foreign key
tblColumn { "targetUser" , "int" , 0 , false , false , "" } , /* the user who created the item the actor is acting on, some items like forums may lack a targetUser field */
tblColumn { "event" , "varchar" , 50 , false , false , "" } , /* mention, like, reply (as in the act of replying to an item, not the reply item type, you can "reply" to a forum by making a topic in it), friend_invite */
tblColumn { "elementType" , "varchar" , 50 , false , false , "" } , /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */
tblColumn { "elementID" , "int" , 0 , false , false , "" } , /* the ID of the element being acted upon */
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "asid" , "primary" } ,
2017-10-16 07:32:58 +00:00
} ,
)
qgen . Install . CreateTable ( "activity_subscriptions" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "user" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "targetID" , "int" , 0 , false , false , "" } , /* the ID of the element being acted upon */
tblColumn { "targetType" , "varchar" , 50 , false , false , "" } , /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */
tblColumn { "level" , "int" , 0 , false , false , "0" } , /* 0: Mentions (aka the global default for any post), 1: Replies To You, 2: All Replies*/
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2017-10-16 07:32:58 +00:00
)
/* Due to MySQL's design, we have to drop the unique keys for table settings, plugins, and themes down from 200 to 180 or it will error */
qgen . Install . CreateTable ( "settings" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "name" , "varchar" , 180 , false , false , "" } ,
tblColumn { "content" , "varchar" , 250 , false , false , "" } ,
tblColumn { "type" , "varchar" , 50 , false , false , "" } ,
tblColumn { "constraints" , "varchar" , 200 , false , false , "''" } ,
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "name" , "unique" } ,
2017-10-16 07:32:58 +00:00
} ,
)
qgen . Install . CreateTable ( "word_filters" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "wfid" , "int" , 0 , false , true , "" } ,
tblColumn { "find" , "varchar" , 200 , false , false , "" } ,
tblColumn { "replacement" , "varchar" , 200 , false , false , "" } ,
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "wfid" , "primary" } ,
2017-10-16 07:32:58 +00:00
} ,
)
qgen . Install . CreateTable ( "plugins" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "uname" , "varchar" , 180 , false , false , "" } ,
tblColumn { "active" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "installed" , "boolean" , 0 , false , false , "0" } ,
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "uname" , "unique" } ,
2017-10-16 07:32:58 +00:00
} ,
)
qgen . Install . CreateTable ( "themes" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "uname" , "varchar" , 180 , false , false , "" } ,
tblColumn { "default" , "boolean" , 0 , false , false , "0" } ,
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "uname" , "unique" } ,
2017-10-16 07:32:58 +00:00
} ,
)
qgen . Install . CreateTable ( "widgets" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "position" , "int" , 0 , false , false , "" } ,
tblColumn { "side" , "varchar" , 100 , false , false , "" } ,
tblColumn { "type" , "varchar" , 100 , false , false , "" } ,
tblColumn { "active" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "location" , "varchar" , 100 , false , false , "" } ,
tblColumn { "data" , "text" , 0 , false , false , "''" } ,
2017-11-12 05:25:04 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2017-10-16 07:32:58 +00:00
)
2018-04-22 12:33:56 +00:00
qgen . Install . CreateTable ( "menus" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "mid" , "int" , 0 , false , true , "" } ,
2018-04-22 12:33:56 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "mid" , "primary" } ,
2018-04-22 12:33:56 +00:00
} ,
)
qgen . Install . CreateTable ( "menu_items" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "miid" , "int" , 0 , false , true , "" } ,
tblColumn { "mid" , "int" , 0 , false , false , "" } ,
tblColumn { "name" , "varchar" , 200 , false , false , "''" } ,
tblColumn { "htmlID" , "varchar" , 200 , false , false , "''" } ,
tblColumn { "cssClass" , "varchar" , 200 , false , false , "''" } ,
tblColumn { "position" , "varchar" , 100 , false , false , "" } ,
tblColumn { "path" , "varchar" , 200 , false , false , "''" } ,
tblColumn { "aria" , "varchar" , 200 , false , false , "''" } ,
tblColumn { "tooltip" , "varchar" , 200 , false , false , "''" } ,
tblColumn { "tmplName" , "varchar" , 200 , false , false , "''" } ,
tblColumn { "order" , "int" , 0 , false , false , "0" } ,
tblColumn { "guestOnly" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "memberOnly" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "staffOnly" , "boolean" , 0 , false , false , "0" } ,
tblColumn { "adminOnly" , "boolean" , 0 , false , false , "0" } ,
} ,
[ ] tblKey {
tblKey { "miid" , "primary" } ,
} ,
)
qgen . Install . CreateTable ( "pages" , mysqlPre , mysqlCol ,
[ ] tblColumn {
tblColumn { "pid" , "int" , 0 , false , true , "" } ,
//tblColumn{"path", "varchar", 200, false, false, ""},
tblColumn { "name" , "varchar" , 200 , false , false , "" } ,
tblColumn { "title" , "varchar" , 200 , false , false , "" } ,
tblColumn { "body" , "text" , 0 , false , false , "" } ,
2018-05-27 09:36:35 +00:00
// TODO: Make this a table?
2018-12-27 05:42:41 +00:00
tblColumn { "allowedGroups" , "text" , 0 , false , false , "" } ,
tblColumn { "menuID" , "int" , 0 , false , false , "-1" } , // simple sidebar menu
2018-05-27 09:36:35 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "pid" , "primary" } ,
2018-05-27 09:36:35 +00:00
} ,
)
2018-05-16 10:46:14 +00:00
qgen . Install . CreateTable ( "registration_logs" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "rlid" , "int" , 0 , false , true , "" } ,
tblColumn { "username" , "varchar" , 100 , false , false , "" } ,
tblColumn { "email" , "varchar" , 100 , false , false , "" } ,
tblColumn { "failureReason" , "varchar" , 100 , false , false , "" } ,
tblColumn { "success" , "bool" , 0 , false , false , "0" } , // Did this attempt succeed?
tblColumn { "ipaddress" , "varchar" , 200 , false , false , "" } ,
tblColumn { "doneAt" , "createdAt" , 0 , false , false , "" } ,
2018-05-16 10:46:14 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "rlid" , "primary" } ,
2018-05-16 10:46:14 +00:00
} ,
)
2018-04-03 04:34:07 +00:00
2018-12-17 04:58:55 +00:00
qgen . Install . CreateTable ( "login_logs" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "lid" , "int" , 0 , false , true , "" } ,
tblColumn { "uid" , "int" , 0 , false , false , "" } ,
tblColumn { "success" , "bool" , 0 , false , false , "0" } , // Did this attempt succeed?
tblColumn { "ipaddress" , "varchar" , 200 , false , false , "" } ,
tblColumn { "doneAt" , "createdAt" , 0 , false , false , "" } ,
2018-12-17 04:58:55 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey {
tblKey { "lid" , "primary" } ,
2018-12-17 04:58:55 +00:00
} ,
)
2018-12-14 04:08:53 +00:00
2017-10-16 07:32:58 +00:00
qgen . Install . CreateTable ( "moderation_logs" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "action" , "varchar" , 100 , false , false , "" } ,
tblColumn { "elementID" , "int" , 0 , false , false , "" } ,
tblColumn { "elementType" , "varchar" , 100 , false , false , "" } ,
tblColumn { "ipaddress" , "varchar" , 200 , false , false , "" } ,
tblColumn { "actorID" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "doneAt" , "datetime" , 0 , false , false , "" } ,
2017-11-12 05:25:04 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2017-10-16 07:32:58 +00:00
)
qgen . Install . CreateTable ( "administration_logs" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "action" , "varchar" , 100 , false , false , "" } ,
tblColumn { "elementID" , "int" , 0 , false , false , "" } ,
tblColumn { "elementType" , "varchar" , 100 , false , false , "" } ,
tblColumn { "ipaddress" , "varchar" , 200 , false , false , "" } ,
tblColumn { "actorID" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
tblColumn { "doneAt" , "datetime" , 0 , false , false , "" } ,
2017-11-12 05:25:04 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2017-10-16 07:32:58 +00:00
)
2017-12-10 03:43:30 +00:00
qgen . Install . CreateTable ( "viewchunks" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "count" , "int" , 0 , false , false , "0" } ,
tblColumn { "createdAt" , "datetime" , 0 , false , false , "" } ,
tblColumn { "route" , "varchar" , 200 , false , false , "" } ,
2017-12-10 03:43:30 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2017-12-10 03:43:30 +00:00
)
2018-01-09 07:39:29 +00:00
qgen . Install . CreateTable ( "viewchunks_agents" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "count" , "int" , 0 , false , false , "0" } ,
tblColumn { "createdAt" , "datetime" , 0 , false , false , "" } ,
tblColumn { "browser" , "varchar" , 200 , false , false , "" } , // googlebot, firefox, opera, etc.
//tblColumn{"version","varchar",0,false,false,""}, // the version of the browser or bot
2018-01-09 07:39:29 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2018-01-09 07:39:29 +00:00
)
2018-02-04 08:15:20 +00:00
qgen . Install . CreateTable ( "viewchunks_systems" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "count" , "int" , 0 , false , false , "0" } ,
tblColumn { "createdAt" , "datetime" , 0 , false , false , "" } ,
tblColumn { "system" , "varchar" , 200 , false , false , "" } , // windows, android, unknown, etc.
2018-02-05 10:29:13 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2018-02-05 10:29:13 +00:00
)
2018-03-08 03:59:47 +00:00
qgen . Install . CreateTable ( "viewchunks_langs" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "count" , "int" , 0 , false , false , "0" } ,
tblColumn { "createdAt" , "datetime" , 0 , false , false , "" } ,
tblColumn { "lang" , "varchar" , 200 , false , false , "" } , // en, ru, etc.
2018-03-08 03:59:47 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2018-03-08 03:59:47 +00:00
)
2018-02-05 10:29:13 +00:00
qgen . Install . CreateTable ( "viewchunks_referrers" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "count" , "int" , 0 , false , false , "0" } ,
tblColumn { "createdAt" , "datetime" , 0 , false , false , "" } ,
tblColumn { "domain" , "varchar" , 200 , false , false , "" } ,
2018-02-04 08:15:20 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2018-02-04 08:15:20 +00:00
)
2018-02-19 04:26:01 +00:00
qgen . Install . CreateTable ( "viewchunks_forums" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "count" , "int" , 0 , false , false , "0" } ,
tblColumn { "createdAt" , "datetime" , 0 , false , false , "" } ,
tblColumn { "forum" , "int" , 0 , false , false , "" } ,
2018-02-19 04:26:01 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2018-02-19 04:26:01 +00:00
)
2017-12-19 03:53:13 +00:00
2018-01-18 12:31:25 +00:00
qgen . Install . CreateTable ( "topicchunks" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "count" , "int" , 0 , false , false , "0" } ,
tblColumn { "createdAt" , "datetime" , 0 , false , false , "" } ,
2018-01-18 12:31:25 +00:00
// TODO: Add a column for the parent forum?
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2018-01-18 12:31:25 +00:00
)
2018-01-14 12:03:20 +00:00
qgen . Install . CreateTable ( "postchunks" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "count" , "int" , 0 , false , false , "0" } ,
tblColumn { "createdAt" , "datetime" , 0 , false , false , "" } ,
2018-01-14 12:03:20 +00:00
// TODO: Add a column for the parent topic / profile?
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2018-01-14 12:03:20 +00:00
)
2017-10-16 07:32:58 +00:00
qgen . Install . CreateTable ( "sync" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "last_update" , "datetime" , 0 , false , false , "" } ,
2017-10-16 07:32:58 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2017-10-16 07:32:58 +00:00
)
2018-12-17 04:58:55 +00:00
qgen . Install . CreateTable ( "updates" , "" , "" ,
2018-12-27 05:42:41 +00:00
[ ] tblColumn {
tblColumn { "dbVersion" , "int" , 0 , false , false , "0" } ,
2018-10-06 13:14:11 +00:00
} ,
2018-12-27 05:42:41 +00:00
[ ] tblKey { } ,
2018-12-17 04:58:55 +00:00
)
2018-10-06 13:14:11 +00:00
2017-10-16 07:32:58 +00:00
return nil
}