Reduce the boilerplate in tables.go

This commit is contained in:
Azareal 2019-07-27 09:18:32 +10:00
parent 093a37e3c7
commit 597240233f

View File

@ -6,43 +6,44 @@ var mysqlPre = "utf8mb4"
var mysqlCol = "utf8mb4_general_ci" var mysqlCol = "utf8mb4_general_ci"
type tblColumn = qgen.DBTableColumn type tblColumn = qgen.DBTableColumn
type tC = tblColumn
type tblKey = qgen.DBTableKey type tblKey = qgen.DBTableKey
func createTables(adapter qgen.Adapter) error { func createTables(adapter qgen.Adapter) error {
qgen.Install.CreateTable("users", mysqlPre, mysqlCol, qgen.Install.CreateTable("users", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"uid", "int", 0, false, true, ""}, tC{"uid", "int", 0, false, true, ""},
tblColumn{"name", "varchar", 100, false, false, ""}, tC{"name", "varchar", 100, false, false, ""},
tblColumn{"password", "varchar", 100, false, false, ""}, tC{"password", "varchar", 100, false, false, ""},
tblColumn{"salt", "varchar", 80, false, false, "''"}, tC{"salt", "varchar", 80, false, false, "''"},
tblColumn{"group", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"group", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"active", "boolean", 0, false, false, "0"}, tC{"active", "boolean", 0, false, false, "0"},
tblColumn{"is_super_admin", "boolean", 0, false, false, "0"}, tC{"is_super_admin", "boolean", 0, false, false, "0"},
tblColumn{"createdAt", "createdAt", 0, false, false, ""}, tC{"createdAt", "createdAt", 0, false, false, ""},
tblColumn{"lastActiveAt", "datetime", 0, false, false, ""}, tC{"lastActiveAt", "datetime", 0, false, false, ""},
tblColumn{"session", "varchar", 200, false, false, "''"}, tC{"session", "varchar", 200, false, false, "''"},
//tblColumn{"authToken", "varchar", 200, false, false, "''"}, //tC{"authToken", "varchar", 200, false, false, "''"},
tblColumn{"last_ip", "varchar", 200, false, false, "0.0.0.0.0"}, tC{"last_ip", "varchar", 200, false, false, "0.0.0.0.0"},
tblColumn{"email", "varchar", 200, false, false, "''"}, tC{"email", "varchar", 200, false, false, "''"},
tblColumn{"avatar", "varchar", 100, false, false, "''"}, tC{"avatar", "varchar", 100, false, false, "''"},
tblColumn{"message", "text", 0, false, false, "''"}, tC{"message", "text", 0, false, false, "''"},
tblColumn{"url_prefix", "varchar", 20, false, false, "''"}, tC{"url_prefix", "varchar", 20, false, false, "''"},
tblColumn{"url_name", "varchar", 100, false, false, "''"}, tC{"url_name", "varchar", 100, false, false, "''"},
tblColumn{"level", "smallint", 0, false, false, "0"}, tC{"level", "smallint", 0, false, false, "0"},
tblColumn{"score", "int", 0, false, false, "0"}, tC{"score", "int", 0, false, false, "0"},
tblColumn{"posts", "int", 0, false, false, "0"}, tC{"posts", "int", 0, false, false, "0"},
tblColumn{"bigposts", "int", 0, false, false, "0"}, tC{"bigposts", "int", 0, false, false, "0"},
tblColumn{"megaposts", "int", 0, false, false, "0"}, tC{"megaposts", "int", 0, false, false, "0"},
tblColumn{"topics", "int", 0, false, false, "0"}, tC{"topics", "int", 0, false, false, "0"},
tblColumn{"liked", "int", 0, false, false, "0"}, tC{"liked", "int", 0, false, false, "0"},
// These two are to bound liked queries with little bits of information we know about the user to reduce the server load // These two are to bound liked queries with little bits of information we know about the user to reduce the server load
tblColumn{"oldestItemLikedCreatedAt", "datetime", 0, false, false, ""}, // For internal use only, semantics may change tC{"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 tC{"lastLiked", "datetime", 0, false, false, ""}, // For internal use only, semantics may change
//tblColumn{"penalty_count","int",0,false,false,"0"}, //tC{"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 tC{"temp_group", "int", 0, false, false, "0"}, // For temporary groups, set this to zero when a temporary group isn't in effect
}, },
[]tblKey{ []tblKey{
tblKey{"uid", "primary","",false}, tblKey{"uid", "primary","",false},
@ -51,17 +52,17 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("users_groups", mysqlPre, mysqlCol, qgen.Install.CreateTable("users_groups", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"gid", "int", 0, false, true, ""}, tC{"gid", "int", 0, false, true, ""},
tblColumn{"name", "varchar", 100, false, false, ""}, tC{"name", "varchar", 100, false, false, ""},
tblColumn{"permissions", "text", 0, false, false, ""}, tC{"permissions", "text", 0, false, false, ""},
tblColumn{"plugin_perms", "text", 0, false, false, ""}, tC{"plugin_perms", "text", 0, false, false, ""},
tblColumn{"is_mod", "boolean", 0, false, false, "0"}, tC{"is_mod", "boolean", 0, false, false, "0"},
tblColumn{"is_admin", "boolean", 0, false, false, "0"}, tC{"is_admin", "boolean", 0, false, false, "0"},
tblColumn{"is_banned", "boolean", 0, false, false, "0"}, tC{"is_banned", "boolean", 0, false, false, "0"},
tblColumn{"user_count", "int", 0, false, false, "0"}, // TODO: Implement this tC{"user_count", "int", 0, false, false, "0"}, // TODO: Implement this
tblColumn{"tag", "varchar", 50, false, false, "''"}, tC{"tag", "varchar", 50, false, false, "''"},
}, },
[]tblKey{ []tblKey{
tblKey{"gid", "primary","",false}, tblKey{"gid", "primary","",false},
@ -69,18 +70,18 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("users_2fa_keys", mysqlPre, mysqlCol, qgen.Install.CreateTable("users_2fa_keys", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"uid", "int", 0, false, false, ""}, tC{"uid", "int", 0, false, false, ""},
tblColumn{"secret", "varchar", 100, false, false, ""}, tC{"secret", "varchar", 100, false, false, ""},
tblColumn{"scratch1", "varchar", 50, false, false, ""}, tC{"scratch1", "varchar", 50, false, false, ""},
tblColumn{"scratch2", "varchar", 50, false, false, ""}, tC{"scratch2", "varchar", 50, false, false, ""},
tblColumn{"scratch3", "varchar", 50, false, false, ""}, tC{"scratch3", "varchar", 50, false, false, ""},
tblColumn{"scratch4", "varchar", 50, false, false, ""}, tC{"scratch4", "varchar", 50, false, false, ""},
tblColumn{"scratch5", "varchar", 50, false, false, ""}, tC{"scratch5", "varchar", 50, false, false, ""},
tblColumn{"scratch6", "varchar", 50, false, false, ""}, tC{"scratch6", "varchar", 50, false, false, ""},
tblColumn{"scratch7", "varchar", 50, false, false, ""}, tC{"scratch7", "varchar", 50, false, false, ""},
tblColumn{"scratch8", "varchar", 50, false, false, ""}, tC{"scratch8", "varchar", 50, false, false, ""},
tblColumn{"createdAt", "createdAt", 0, false, false, ""}, tC{"createdAt", "createdAt", 0, false, false, ""},
}, },
[]tblKey{ []tblKey{
tblKey{"uid", "primary","",false}, tblKey{"uid", "primary","",false},
@ -94,38 +95,38 @@ func createTables(adapter qgen.Adapter) error {
// TODO: Add a penalty type where a user is stopped from creating plugin_guilds social groups // TODO: Add a penalty type where a user is stopped from creating plugin_guilds social groups
// TODO: Shadow bans. We will probably have a CanShadowBan permission for this, as we *really* don't want people using this lightly. // 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","","", /*qgen.Install.CreateTable("users_penalties","","",
[]tblColumn{ []tC{
tblColumn{"uid","int",0,false,false,""}, tC{"uid","int",0,false,false,""},
tblColumn{"element_id","int",0,false,false,""}, tC{"element_id","int",0,false,false,""},
tblColumn{"element_type","varchar",50,false,false,""}, //forum, profile?, and social_group. Leave blank for global. tC{"element_type","varchar",50,false,false,""}, //forum, profile?, and social_group. Leave blank for global.
tblColumn{"overrides","text",0,false,false,"{}"}, tC{"overrides","text",0,false,false,"{}"},
tblColumn{"mod_queue","boolean",0,false,false,"0"}, tC{"mod_queue","boolean",0,false,false,"0"},
tblColumn{"shadow_ban","boolean",0,false,false,"0"}, tC{"shadow_ban","boolean",0,false,false,"0"},
tblColumn{"no_avatar","boolean",0,false,false,"0"}, // Coming Soon. Should this be a perm override instead? tC{"no_avatar","boolean",0,false,false,"0"}, // Coming Soon. Should this be a perm override instead?
// Do we *really* need rate-limit penalty types? Are we going to be allowing bots or something? // Do we *really* need rate-limit penalty types? Are we going to be allowing bots or something?
//tblColumn{"posts_per_hour","int",0,false,false,"0"}, //tC{"posts_per_hour","int",0,false,false,"0"},
//tblColumn{"topics_per_hour","int",0,false,false,"0"}, //tC{"topics_per_hour","int",0,false,false,"0"},
//tblColumn{"posts_count","int",0,false,false,"0"}, //tC{"posts_count","int",0,false,false,"0"},
//tblColumn{"topic_count","int",0,false,false,"0"}, //tC{"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. //tC{"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.
tblColumn{"issued_by","int",0,false,false,""}, tC{"issued_by","int",0,false,false,""},
tblColumn{"issued_at","createdAt",0,false,false,""}, tC{"issued_at","createdAt",0,false,false,""},
tblColumn{"expires_at","datetime",0,false,false,""}, tC{"expires_at","datetime",0,false,false,""},
}, nil, }, nil,
)*/ )*/
qgen.Install.CreateTable("users_groups_scheduler", "", "", qgen.Install.CreateTable("users_groups_scheduler", "", "",
[]tblColumn{ []tC{
tblColumn{"uid", "int", 0, false, false, ""}, tC{"uid", "int", 0, false, false, ""},
tblColumn{"set_group", "int", 0, false, false, ""}, tC{"set_group", "int", 0, false, false, ""},
tblColumn{"issued_by", "int", 0, false, false, ""}, tC{"issued_by", "int", 0, false, false, ""},
tblColumn{"issued_at", "createdAt", 0, false, false, ""}, tC{"issued_at", "createdAt", 0, false, false, ""},
tblColumn{"revert_at", "datetime", 0, false, false, ""}, tC{"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 tC{"temporary", "boolean", 0, false, false, ""}, // special case for permanent bans to do the necessary bookkeeping, might be removed in the future
}, },
[]tblKey{ []tblKey{
tblKey{"uid", "primary","",false}, tblKey{"uid", "primary","",false},
@ -134,8 +135,8 @@ func createTables(adapter qgen.Adapter) error {
// TODO: Can we use a piece of software dedicated to persistent queues for this rather than relying on the database for it? // 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", "", "", qgen.Install.CreateTable("users_avatar_queue", "", "",
[]tblColumn{ []tC{
tblColumn{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
}, },
[]tblKey{ []tblKey{
tblKey{"uid", "primary","",false}, tblKey{"uid", "primary","",false},
@ -144,20 +145,20 @@ func createTables(adapter qgen.Adapter) error {
// TODO: Should we add a users prefix to this table to fit the "unofficial convention"? // TODO: Should we add a users prefix to this table to fit the "unofficial convention"?
qgen.Install.CreateTable("emails", "", "", qgen.Install.CreateTable("emails", "", "",
[]tblColumn{ []tC{
tblColumn{"email", "varchar", 200, false, false, ""}, tC{"email", "varchar", 200, false, false, ""},
tblColumn{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"validated", "boolean", 0, false, false, "0"}, tC{"validated", "boolean", 0, false, false, "0"},
tblColumn{"token", "varchar", 200, false, false, "''"}, tC{"token", "varchar", 200, false, false, "''"},
}, nil, }, nil,
) )
// TODO: Allow for patterns in domains, if the bots try to shake things up there? // TODO: Allow for patterns in domains, if the bots try to shake things up there?
/* /*
qgen.Install.CreateTable("email_domain_blacklist", "", "", qgen.Install.CreateTable("email_domain_blacklist", "", "",
[]tblColumn{ []tC{
tblColumn{"domain", "varchar", 200, false, false, ""}, tC{"domain", "varchar", 200, false, false, ""},
tblColumn{"gtld", "boolean", 0, false, false, "0"}, tC{"gtld", "boolean", 0, false, false, "0"},
}, },
[]tblKey{ []tblKey{
tblKey{"domain", "primary"}, tblKey{"domain", "primary"},
@ -167,29 +168,29 @@ func createTables(adapter qgen.Adapter) error {
// TODO: Implement password resets // TODO: Implement password resets
qgen.Install.CreateTable("password_resets", "", "", qgen.Install.CreateTable("password_resets", "", "",
[]tblColumn{ []tC{
tblColumn{"email", "varchar", 200, false, false, ""}, tC{"email", "varchar", 200, false, false, ""},
tblColumn{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"validated", "varchar", 200, false, false, ""}, // Token given once the one-use token is consumed, used to prevent multiple people consuming the same one-use token tC{"validated", "varchar", 200, false, false, ""}, // Token given once the one-use token is consumed, used to prevent multiple people consuming the same one-use token
tblColumn{"token", "varchar", 200, false, false, ""}, tC{"token", "varchar", 200, false, false, ""},
tblColumn{"createdAt", "createdAt", 0, false, false, ""}, tC{"createdAt", "createdAt", 0, false, false, ""},
}, nil, }, nil,
) )
qgen.Install.CreateTable("forums", mysqlPre, mysqlCol, qgen.Install.CreateTable("forums", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"fid", "int", 0, false, true, ""}, tC{"fid", "int", 0, false, true, ""},
tblColumn{"name", "varchar", 100, false, false, ""}, tC{"name", "varchar", 100, false, false, ""},
tblColumn{"desc", "varchar", 200, false, false, ""}, tC{"desc", "varchar", 200, false, false, ""},
tblColumn{"tmpl", "varchar", 200, false, false, "''"}, tC{"tmpl", "varchar", 200, false, false, "''"},
tblColumn{"active", "boolean", 0, false, false, "1"}, tC{"active", "boolean", 0, false, false, "1"},
tblColumn{"order", "int", 0, false, false, "0"}, tC{"order", "int", 0, false, false, "0"},
tblColumn{"topicCount", "int", 0, false, false, "0"}, tC{"topicCount", "int", 0, false, false, "0"},
tblColumn{"preset", "varchar", 100, false, false, "''"}, tC{"preset", "varchar", 100, false, false, "''"},
tblColumn{"parentID", "int", 0, false, false, "0"}, tC{"parentID", "int", 0, false, false, "0"},
tblColumn{"parentType", "varchar", 50, false, false, "''"}, tC{"parentType", "varchar", 50, false, false, "''"},
tblColumn{"lastTopicID", "int", 0, false, false, "0"}, tC{"lastTopicID", "int", 0, false, false, "0"},
tblColumn{"lastReplyerID", "int", 0, false, false, "0"}, tC{"lastReplyerID", "int", 0, false, false, "0"},
}, },
[]tblKey{ []tblKey{
tblKey{"fid", "primary","",false}, tblKey{"fid", "primary","",false},
@ -197,11 +198,11 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("forums_permissions", "", "", qgen.Install.CreateTable("forums_permissions", "", "",
[]tblColumn{ []tC{
tblColumn{"fid", "int", 0, false, false, ""}, tC{"fid", "int", 0, false, false, ""},
tblColumn{"gid", "int", 0, false, false, ""}, tC{"gid", "int", 0, false, false, ""},
tblColumn{"preset", "varchar", 100, false, false, "''"}, tC{"preset", "varchar", 100, false, false, "''"},
tblColumn{"permissions", "text", 0, false, false, ""}, tC{"permissions", "text", 0, false, false, ""},
}, },
[]tblKey{ []tblKey{
// TODO: Test to see that the compound primary key works // TODO: Test to see that the compound primary key works
@ -210,35 +211,35 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("topics", mysqlPre, mysqlCol, qgen.Install.CreateTable("topics", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"tid", "int", 0, false, true, ""}, tC{"tid", "int", 0, false, true, ""},
tblColumn{"title", "varchar", 100, false, false, ""}, // TODO: Increase the max length to 200? tC{"title", "varchar", 100, false, false, ""}, // TODO: Increase the max length to 200?
tblColumn{"content", "text", 0, false, false, ""}, tC{"content", "text", 0, false, false, ""},
tblColumn{"parsed_content", "text", 0, false, false, ""}, tC{"parsed_content", "text", 0, false, false, ""},
tblColumn{"createdAt", "createdAt", 0, false, false, ""}, tC{"createdAt", "createdAt", 0, false, false, ""},
tblColumn{"lastReplyAt", "datetime", 0, false, false, ""}, tC{"lastReplyAt", "datetime", 0, false, false, ""},
tblColumn{"lastReplyBy", "int", 0, false, false, ""}, tC{"lastReplyBy", "int", 0, false, false, ""},
tblColumn{"lastReplyID", "int", 0, false, false, "0"}, tC{"lastReplyID", "int", 0, false, false, "0"},
tblColumn{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"is_closed", "boolean", 0, false, false, "0"}, tC{"is_closed", "boolean", 0, false, false, "0"},
tblColumn{"sticky", "boolean", 0, false, false, "0"}, tC{"sticky", "boolean", 0, false, false, "0"},
// TODO: Add an index for this // TODO: Add an index for this
tblColumn{"parentID", "int", 0, false, false, "2"}, tC{"parentID", "int", 0, false, false, "2"},
tblColumn{"ipaddress", "varchar", 200, false, false, "0.0.0.0.0"}, tC{"ipaddress", "varchar", 200, false, false, "0.0.0.0.0"},
tblColumn{"postCount", "int", 0, false, false, "1"}, tC{"postCount", "int", 0, false, false, "1"},
tblColumn{"likeCount", "int", 0, false, false, "0"}, tC{"likeCount", "int", 0, false, false, "0"},
tblColumn{"attachCount", "int", 0, false, false, "0"}, tC{"attachCount", "int", 0, false, false, "0"},
tblColumn{"words", "int", 0, false, false, "0"}, tC{"words", "int", 0, false, false, "0"},
tblColumn{"views", "int", 0, false, false, "0"}, tC{"views", "int", 0, false, false, "0"},
//tblColumn{"dailyViews", "int", 0, false, false, "0"}, //tC{"dailyViews", "int", 0, false, false, "0"},
//tblColumn{"weeklyViews", "int", 0, false, false, "0"}, //tC{"weeklyViews", "int", 0, false, false, "0"},
//tblColumn{"monthlyViews", "int", 0, false, false, "0"}, //tC{"monthlyViews", "int", 0, false, false, "0"},
// ? - A little hacky, maybe we could do something less likely to bite us with huge numbers of topics? // ? - A little hacky, maybe we could do something less likely to bite us with huge numbers of topics?
// TODO: Add an index for this? // TODO: Add an index for this?
//tblColumn{"lastMonth", "datetime", 0, false, false, ""}, //tC{"lastMonth", "datetime", 0, false, false, ""},
tblColumn{"css_class", "varchar", 100, false, false, "''"}, tC{"css_class", "varchar", 100, false, false, "''"},
tblColumn{"poll", "int", 0, false, false, "0"}, tC{"poll", "int", 0, false, false, "0"},
tblColumn{"data", "varchar", 200, false, false, "''"}, tC{"data", "varchar", 200, false, false, "''"},
}, },
[]tblKey{ []tblKey{
tblKey{"tid", "primary","",false}, tblKey{"tid", "primary","",false},
@ -247,22 +248,22 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("replies", mysqlPre, mysqlCol, qgen.Install.CreateTable("replies", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"rid", "int", 0, false, true, ""}, // TODO: Rename to replyID? tC{"rid", "int", 0, false, true, ""}, // TODO: Rename to replyID?
tblColumn{"tid", "int", 0, false, false, ""}, // TODO: Rename to topicID? tC{"tid", "int", 0, false, false, ""}, // TODO: Rename to topicID?
tblColumn{"content", "text", 0, false, false, ""}, tC{"content", "text", 0, false, false, ""},
tblColumn{"parsed_content", "text", 0, false, false, ""}, tC{"parsed_content", "text", 0, false, false, ""},
tblColumn{"createdAt", "createdAt", 0, false, false, ""}, tC{"createdAt", "createdAt", 0, false, false, ""},
tblColumn{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"lastEdit", "int", 0, false, false, "0"}, tC{"lastEdit", "int", 0, false, false, "0"},
tblColumn{"lastEditBy", "int", 0, false, false, "0"}, tC{"lastEditBy", "int", 0, false, false, "0"},
tblColumn{"lastUpdated", "datetime", 0, false, false, ""}, tC{"lastUpdated", "datetime", 0, false, false, ""},
tblColumn{"ipaddress", "varchar", 200, false, false, "0.0.0.0.0"}, tC{"ipaddress", "varchar", 200, false, false, "0.0.0.0.0"},
tblColumn{"likeCount", "int", 0, false, false, "0"}, tC{"likeCount", "int", 0, false, false, "0"},
tblColumn{"attachCount", "int", 0, false, false, "0"}, tC{"attachCount", "int", 0, false, false, "0"},
tblColumn{"words", "int", 0, false, false, "1"}, // ? - replies has a default of 1 and topics has 0? why? tC{"words", "int", 0, false, false, "1"}, // ? - replies has a default of 1 and topics has 0? why?
tblColumn{"actionType", "varchar", 20, false, false, "''"}, tC{"actionType", "varchar", 20, false, false, "''"},
tblColumn{"poll", "int", 0, false, false, "0"}, tC{"poll", "int", 0, false, false, "0"},
}, },
[]tblKey{ []tblKey{
tblKey{"rid", "primary","",false}, tblKey{"rid", "primary","",false},
@ -271,15 +272,15 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("attachments", mysqlPre, mysqlCol, qgen.Install.CreateTable("attachments", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"attachID", "int", 0, false, true, ""}, tC{"attachID", "int", 0, false, true, ""},
tblColumn{"sectionID", "int", 0, false, false, "0"}, tC{"sectionID", "int", 0, false, false, "0"},
tblColumn{"sectionTable", "varchar", 200, false, false, "forums"}, tC{"sectionTable", "varchar", 200, false, false, "forums"},
tblColumn{"originID", "int", 0, false, false, ""}, tC{"originID", "int", 0, false, false, ""},
tblColumn{"originTable", "varchar", 200, false, false, "replies"}, tC{"originTable", "varchar", 200, false, false, "replies"},
tblColumn{"uploadedBy", "int", 0, false, false, ""}, // TODO; Make this a foreign key tC{"uploadedBy", "int", 0, false, false, ""}, // TODO; Make this a foreign key
tblColumn{"path", "varchar", 200, false, false, ""}, tC{"path", "varchar", 200, false, false, ""},
tblColumn{"extra", "varchar", 200, false, false, ""}, tC{"extra", "varchar", 200, false, false, ""},
}, },
[]tblKey{ []tblKey{
tblKey{"attachID", "primary","",false}, tblKey{"attachID", "primary","",false},
@ -287,12 +288,12 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("revisions", mysqlPre, mysqlCol, qgen.Install.CreateTable("revisions", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"reviseID", "int", 0, false, true, ""}, tC{"reviseID", "int", 0, false, true, ""},
tblColumn{"content", "text", 0, false, false, ""}, tC{"content", "text", 0, false, false, ""},
tblColumn{"contentID", "int", 0, false, false, ""}, tC{"contentID", "int", 0, false, false, ""},
tblColumn{"contentType", "varchar", 100, false, false, "replies"}, tC{"contentType", "varchar", 100, false, false, "replies"},
tblColumn{"createdAt", "createdAt", 0, false, false, ""}, tC{"createdAt", "createdAt", 0, false, false, ""},
// TODO: Add a createdBy column? // TODO: Add a createdBy column?
}, },
[]tblKey{ []tblKey{
@ -301,13 +302,13 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("polls", mysqlPre, mysqlCol, qgen.Install.CreateTable("polls", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"pollID", "int", 0, false, true, ""}, tC{"pollID", "int", 0, false, true, ""},
tblColumn{"parentID", "int", 0, false, false, "0"}, tC{"parentID", "int", 0, false, false, "0"},
tblColumn{"parentTable", "varchar", 100, false, false, "topics"}, // topics, replies tC{"parentTable", "varchar", 100, false, false, "topics"}, // topics, replies
tblColumn{"type", "int", 0, false, false, "0"}, tC{"type", "int", 0, false, false, "0"},
tblColumn{"options", "json", 0, false, false, ""}, tC{"options", "json", 0, false, false, ""},
tblColumn{"votes", "int", 0, false, false, "0"}, tC{"votes", "int", 0, false, false, "0"},
}, },
[]tblKey{ []tblKey{
tblKey{"pollID", "primary","",false}, tblKey{"pollID", "primary","",false},
@ -315,34 +316,34 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("polls_options", "", "", qgen.Install.CreateTable("polls_options", "", "",
[]tblColumn{ []tC{
tblColumn{"pollID", "int", 0, false, false, ""}, tC{"pollID", "int", 0, false, false, ""},
tblColumn{"option", "int", 0, false, false, "0"}, tC{"option", "int", 0, false, false, "0"},
tblColumn{"votes", "int", 0, false, false, "0"}, tC{"votes", "int", 0, false, false, "0"},
}, nil, }, nil,
) )
qgen.Install.CreateTable("polls_votes", mysqlPre, mysqlCol, qgen.Install.CreateTable("polls_votes", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"pollID", "int", 0, false, false, ""}, tC{"pollID", "int", 0, false, false, ""},
tblColumn{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"option", "int", 0, false, false, "0"}, tC{"option", "int", 0, false, false, "0"},
tblColumn{"castAt", "createdAt", 0, false, false, ""}, tC{"castAt", "createdAt", 0, false, false, ""},
tblColumn{"ipaddress", "varchar", 200, false, false, "0.0.0.0.0"}, tC{"ipaddress", "varchar", 200, false, false, "0.0.0.0.0"},
}, nil, }, nil,
) )
qgen.Install.CreateTable("users_replies", mysqlPre, mysqlCol, qgen.Install.CreateTable("users_replies", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"rid", "int", 0, false, true, ""}, tC{"rid", "int", 0, false, true, ""},
tblColumn{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"content", "text", 0, false, false, ""}, tC{"content", "text", 0, false, false, ""},
tblColumn{"parsed_content", "text", 0, false, false, ""}, tC{"parsed_content", "text", 0, false, false, ""},
tblColumn{"createdAt", "createdAt", 0, false, false, ""}, tC{"createdAt", "createdAt", 0, false, false, ""},
tblColumn{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"lastEdit", "int", 0, false, false, "0"}, tC{"lastEdit", "int", 0, false, false, "0"},
tblColumn{"lastEditBy", "int", 0, false, false, "0"}, tC{"lastEditBy", "int", 0, false, false, "0"},
tblColumn{"ipaddress", "varchar", 200, false, false, "0.0.0.0.0"}, tC{"ipaddress", "varchar", 200, false, false, "0.0.0.0.0"},
}, },
[]tblKey{ []tblKey{
tblKey{"rid", "primary","",false}, tblKey{"rid", "primary","",false},
@ -350,20 +351,54 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("likes", "", "", qgen.Install.CreateTable("likes", "", "",
[]tblColumn{ []tC{
tblColumn{"weight", "tinyint", 0, false, false, "1"}, tC{"weight", "tinyint", 0, false, false, "1"},
tblColumn{"targetItem", "int", 0, false, false, ""}, tC{"targetItem", "int", 0, false, false, ""},
tblColumn{"targetType", "varchar", 50, false, false, "replies"}, tC{"targetType", "varchar", 50, false, false, "replies"},
tblColumn{"sentBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"sentBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"createdAt", "createdAt", 0, false, false, ""}, tC{"createdAt", "createdAt", 0, false, false, ""},
tblColumn{"recalc", "tinyint", 0, false, false, "0"}, tC{"recalc", "tinyint", 0, false, false, "0"},
}, nil, }, nil,
) )
//columns("participants, createdBy, createdAt, lastReplyBy, lastReplyAt").Where("cid = ?")
/*qgen.Install.CreateTable("conversations", "", "",
[]tC{
tC{"cid", "int", 0, false, true, ""},
tC{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tC{"createdAt", "createdAt", 0, false, false, ""},
tC{"lastReplyAt", "datetime", 0, false, false, ""},
tC{"lastReplyBy", "int", 0, false, false, ""},
},
[]tblKey{
tblKey{"cid", "primary","",false},
},
)
qgen.Install.CreateTable("conversations_posts", "", "",
[]tC{
tC{"pid", "int", 0, false, true, ""},
tC{"cid", "int", 0, false, false, ""},
tC{"createdBy", "int", 0, false, false, ""},
tC{"body", "varchar", 50, false, false, ""},
tC{"post", "varchar", 50, false, false, "''"},
},
[]tblKey{
tblKey{"pid", "primary","",false},
},
)
qgen.Install.CreateTable("conversations_participants", "", "",
[]tC{
tC{"uid", "int", 0, false, false, ""},
tC{"cid", "int", 0, false, false, ""},
}, nil,
)*/
qgen.Install.CreateTable("activity_stream_matches", "", "", qgen.Install.CreateTable("activity_stream_matches", "", "",
[]tblColumn{ []tC{
tblColumn{"watcher", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"watcher", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"asid", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"asid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
}, },
[]tblKey{ []tblKey{
tblKey{"asid,asid","foreign","activity_stream",true}, tblKey{"asid,asid","foreign","activity_stream",true},
@ -371,14 +406,14 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("activity_stream", "", "", qgen.Install.CreateTable("activity_stream", "", "",
[]tblColumn{ []tC{
tblColumn{"asid", "int", 0, false, true, ""}, tC{"asid", "int", 0, false, true, ""},
tblColumn{"actor", "int", 0, false, false, ""}, /* the one doing the act */ // TODO: Make this a foreign key tC{"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 */ tC{"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 */ tC{"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 */ tC{"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 */ tC{"elementID", "int", 0, false, false, ""}, /* the ID of the element being acted upon */
tblColumn{"createdAt", "createdAt", 0, false, false, ""}, tC{"createdAt", "createdAt", 0, false, false, ""},
}, },
[]tblKey{ []tblKey{
tblKey{"asid", "primary","",false}, tblKey{"asid", "primary","",false},
@ -386,21 +421,21 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("activity_subscriptions", "", "", qgen.Install.CreateTable("activity_subscriptions", "", "",
[]tblColumn{ []tC{
tblColumn{"user", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"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 */ tC{"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 */ tC{"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*/ tC{"level", "int", 0, false, false, "0"}, /* 0: Mentions (aka the global default for any post), 1: Replies To You, 2: All Replies*/
}, nil, }, nil,
) )
/* 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 */ /* 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", "", "", qgen.Install.CreateTable("settings", "", "",
[]tblColumn{ []tC{
tblColumn{"name", "varchar", 180, false, false, ""}, tC{"name", "varchar", 180, false, false, ""},
tblColumn{"content", "varchar", 250, false, false, ""}, tC{"content", "varchar", 250, false, false, ""},
tblColumn{"type", "varchar", 50, false, false, ""}, tC{"type", "varchar", 50, false, false, ""},
tblColumn{"constraints", "varchar", 200, false, false, "''"}, tC{"constraints", "varchar", 200, false, false, "''"},
}, },
[]tblKey{ []tblKey{
tblKey{"name", "unique","",false}, tblKey{"name", "unique","",false},
@ -408,10 +443,10 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("word_filters", "", "", qgen.Install.CreateTable("word_filters", "", "",
[]tblColumn{ []tC{
tblColumn{"wfid", "int", 0, false, true, ""}, tC{"wfid", "int", 0, false, true, ""},
tblColumn{"find", "varchar", 200, false, false, ""}, tC{"find", "varchar", 200, false, false, ""},
tblColumn{"replacement", "varchar", 200, false, false, ""}, tC{"replacement", "varchar", 200, false, false, ""},
}, },
[]tblKey{ []tblKey{
tblKey{"wfid", "primary","",false}, tblKey{"wfid", "primary","",false},
@ -419,10 +454,10 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("plugins", "", "", qgen.Install.CreateTable("plugins", "", "",
[]tblColumn{ []tC{
tblColumn{"uname", "varchar", 180, false, false, ""}, tC{"uname", "varchar", 180, false, false, ""},
tblColumn{"active", "boolean", 0, false, false, "0"}, tC{"active", "boolean", 0, false, false, "0"},
tblColumn{"installed", "boolean", 0, false, false, "0"}, tC{"installed", "boolean", 0, false, false, "0"},
}, },
[]tblKey{ []tblKey{
tblKey{"uname", "unique","",false}, tblKey{"uname", "unique","",false},
@ -430,10 +465,10 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("themes", "", "", qgen.Install.CreateTable("themes", "", "",
[]tblColumn{ []tC{
tblColumn{"uname", "varchar", 180, false, false, ""}, tC{"uname", "varchar", 180, false, false, ""},
tblColumn{"default", "boolean", 0, false, false, "0"}, tC{"default", "boolean", 0, false, false, "0"},
//tblColumn{"profileUserVars", "text", 0, false, false, "''"}, //tC{"profileUserVars", "text", 0, false, false, "''"},
}, },
[]tblKey{ []tblKey{
tblKey{"uname", "unique","",false}, tblKey{"uname", "unique","",false},
@ -441,14 +476,14 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("widgets", "", "", qgen.Install.CreateTable("widgets", "", "",
[]tblColumn{ []tC{
tblColumn{"wid", "int", 0, false, true, ""}, tC{"wid", "int", 0, false, true, ""},
tblColumn{"position", "int", 0, false, false, ""}, tC{"position", "int", 0, false, false, ""},
tblColumn{"side", "varchar", 100, false, false, ""}, tC{"side", "varchar", 100, false, false, ""},
tblColumn{"type", "varchar", 100, false, false, ""}, tC{"type", "varchar", 100, false, false, ""},
tblColumn{"active", "boolean", 0, false, false, "0"}, tC{"active", "boolean", 0, false, false, "0"},
tblColumn{"location", "varchar", 100, false, false, ""}, tC{"location", "varchar", 100, false, false, ""},
tblColumn{"data", "text", 0, false, false, "''"}, tC{"data", "text", 0, false, false, "''"},
}, },
[]tblKey{ []tblKey{
tblKey{"wid", "primary","",false}, tblKey{"wid", "primary","",false},
@ -456,8 +491,8 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("menus", "", "", qgen.Install.CreateTable("menus", "", "",
[]tblColumn{ []tC{
tblColumn{"mid", "int", 0, false, true, ""}, tC{"mid", "int", 0, false, true, ""},
}, },
[]tblKey{ []tblKey{
tblKey{"mid", "primary","",false}, tblKey{"mid", "primary","",false},
@ -465,23 +500,23 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("menu_items", "", "", qgen.Install.CreateTable("menu_items", "", "",
[]tblColumn{ []tC{
tblColumn{"miid", "int", 0, false, true, ""}, tC{"miid", "int", 0, false, true, ""},
tblColumn{"mid", "int", 0, false, false, ""}, tC{"mid", "int", 0, false, false, ""},
tblColumn{"name", "varchar", 200, false, false, "''"}, tC{"name", "varchar", 200, false, false, "''"},
tblColumn{"htmlID", "varchar", 200, false, false, "''"}, tC{"htmlID", "varchar", 200, false, false, "''"},
tblColumn{"cssClass", "varchar", 200, false, false, "''"}, tC{"cssClass", "varchar", 200, false, false, "''"},
tblColumn{"position", "varchar", 100, false, false, ""}, tC{"position", "varchar", 100, false, false, ""},
tblColumn{"path", "varchar", 200, false, false, "''"}, tC{"path", "varchar", 200, false, false, "''"},
tblColumn{"aria", "varchar", 200, false, false, "''"}, tC{"aria", "varchar", 200, false, false, "''"},
tblColumn{"tooltip", "varchar", 200, false, false, "''"}, tC{"tooltip", "varchar", 200, false, false, "''"},
tblColumn{"tmplName", "varchar", 200, false, false, "''"}, tC{"tmplName", "varchar", 200, false, false, "''"},
tblColumn{"order", "int", 0, false, false, "0"}, tC{"order", "int", 0, false, false, "0"},
tblColumn{"guestOnly", "boolean", 0, false, false, "0"}, tC{"guestOnly", "boolean", 0, false, false, "0"},
tblColumn{"memberOnly", "boolean", 0, false, false, "0"}, tC{"memberOnly", "boolean", 0, false, false, "0"},
tblColumn{"staffOnly", "boolean", 0, false, false, "0"}, tC{"staffOnly", "boolean", 0, false, false, "0"},
tblColumn{"adminOnly", "boolean", 0, false, false, "0"}, tC{"adminOnly", "boolean", 0, false, false, "0"},
}, },
[]tblKey{ []tblKey{
tblKey{"miid", "primary","",false}, tblKey{"miid", "primary","",false},
@ -489,15 +524,15 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("pages", mysqlPre, mysqlCol, qgen.Install.CreateTable("pages", mysqlPre, mysqlCol,
[]tblColumn{ []tC{
tblColumn{"pid", "int", 0, false, true, ""}, tC{"pid", "int", 0, false, true, ""},
//tblColumn{"path", "varchar", 200, false, false, ""}, //tC{"path", "varchar", 200, false, false, ""},
tblColumn{"name", "varchar", 200, false, false, ""}, tC{"name", "varchar", 200, false, false, ""},
tblColumn{"title", "varchar", 200, false, false, ""}, tC{"title", "varchar", 200, false, false, ""},
tblColumn{"body", "text", 0, false, false, ""}, tC{"body", "text", 0, false, false, ""},
// TODO: Make this a table? // TODO: Make this a table?
tblColumn{"allowedGroups", "text", 0, false, false, ""}, tC{"allowedGroups", "text", 0, false, false, ""},
tblColumn{"menuID", "int", 0, false, false, "-1"}, // simple sidebar menu tC{"menuID", "int", 0, false, false, "-1"}, // simple sidebar menu
}, },
[]tblKey{ []tblKey{
tblKey{"pid", "primary","",false}, tblKey{"pid", "primary","",false},
@ -505,14 +540,14 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("registration_logs", "", "", qgen.Install.CreateTable("registration_logs", "", "",
[]tblColumn{ []tC{
tblColumn{"rlid", "int", 0, false, true, ""}, tC{"rlid", "int", 0, false, true, ""},
tblColumn{"username", "varchar", 100, false, false, ""}, tC{"username", "varchar", 100, false, false, ""},
tblColumn{"email", "varchar", 100, false, false, ""}, tC{"email", "varchar", 100, false, false, ""},
tblColumn{"failureReason", "varchar", 100, false, false, ""}, tC{"failureReason", "varchar", 100, false, false, ""},
tblColumn{"success", "bool", 0, false, false, "0"}, // Did this attempt succeed? tC{"success", "bool", 0, false, false, "0"}, // Did this attempt succeed?
tblColumn{"ipaddress", "varchar", 200, false, false, ""}, tC{"ipaddress", "varchar", 200, false, false, ""},
tblColumn{"doneAt", "createdAt", 0, false, false, ""}, tC{"doneAt", "createdAt", 0, false, false, ""},
}, },
[]tblKey{ []tblKey{
tblKey{"rlid", "primary","",false}, tblKey{"rlid", "primary","",false},
@ -520,12 +555,12 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("login_logs", "", "", qgen.Install.CreateTable("login_logs", "", "",
[]tblColumn{ []tC{
tblColumn{"lid", "int", 0, false, true, ""}, tC{"lid", "int", 0, false, true, ""},
tblColumn{"uid", "int", 0, false, false, ""}, tC{"uid", "int", 0, false, false, ""},
tblColumn{"success", "bool", 0, false, false, "0"}, // Did this attempt succeed? tC{"success", "bool", 0, false, false, "0"}, // Did this attempt succeed?
tblColumn{"ipaddress", "varchar", 200, false, false, ""}, tC{"ipaddress", "varchar", 200, false, false, ""},
tblColumn{"doneAt", "createdAt", 0, false, false, ""}, tC{"doneAt", "createdAt", 0, false, false, ""},
}, },
[]tblKey{ []tblKey{
tblKey{"lid", "primary","",false}, tblKey{"lid", "primary","",false},
@ -533,117 +568,117 @@ func createTables(adapter qgen.Adapter) error {
) )
qgen.Install.CreateTable("moderation_logs", "", "", qgen.Install.CreateTable("moderation_logs", "", "",
[]tblColumn{ []tC{
tblColumn{"action", "varchar", 100, false, false, ""}, tC{"action", "varchar", 100, false, false, ""},
tblColumn{"elementID", "int", 0, false, false, ""}, tC{"elementID", "int", 0, false, false, ""},
tblColumn{"elementType", "varchar", 100, false, false, ""}, tC{"elementType", "varchar", 100, false, false, ""},
tblColumn{"ipaddress", "varchar", 200, false, false, ""}, tC{"ipaddress", "varchar", 200, false, false, ""},
tblColumn{"actorID", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"actorID", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"doneAt", "datetime", 0, false, false, ""}, tC{"doneAt", "datetime", 0, false, false, ""},
}, nil, }, nil,
) )
qgen.Install.CreateTable("administration_logs", "", "", qgen.Install.CreateTable("administration_logs", "", "",
[]tblColumn{ []tC{
tblColumn{"action", "varchar", 100, false, false, ""}, tC{"action", "varchar", 100, false, false, ""},
tblColumn{"elementID", "int", 0, false, false, ""}, tC{"elementID", "int", 0, false, false, ""},
tblColumn{"elementType", "varchar", 100, false, false, ""}, tC{"elementType", "varchar", 100, false, false, ""},
tblColumn{"ipaddress", "varchar", 200, false, false, ""}, tC{"ipaddress", "varchar", 200, false, false, ""},
tblColumn{"actorID", "int", 0, false, false, ""}, // TODO: Make this a foreign key tC{"actorID", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tblColumn{"doneAt", "datetime", 0, false, false, ""}, tC{"doneAt", "datetime", 0, false, false, ""},
}, nil, }, nil,
) )
qgen.Install.CreateTable("viewchunks", "", "", qgen.Install.CreateTable("viewchunks", "", "",
[]tblColumn{ []tC{
tblColumn{"count", "int", 0, false, false, "0"}, tC{"count", "int", 0, false, false, "0"},
tblColumn{"createdAt", "datetime", 0, false, false, ""}, tC{"createdAt", "datetime", 0, false, false, ""},
tblColumn{"route", "varchar", 200, false, false, ""}, tC{"route", "varchar", 200, false, false, ""}, // todo: set a default empty here
}, nil, }, nil,
) )
qgen.Install.CreateTable("viewchunks_agents", "", "", qgen.Install.CreateTable("viewchunks_agents", "", "",
[]tblColumn{ []tC{
tblColumn{"count", "int", 0, false, false, "0"}, tC{"count", "int", 0, false, false, "0"},
tblColumn{"createdAt", "datetime", 0, false, false, ""}, tC{"createdAt", "datetime", 0, false, false, ""},
tblColumn{"browser", "varchar", 200, false, false, ""}, // googlebot, firefox, opera, etc. tC{"browser", "varchar", 200, false, false, ""}, // googlebot, firefox, opera, etc.
//tblColumn{"version","varchar",0,false,false,""}, // the version of the browser or bot //tC{"version","varchar",0,false,false,""}, // the version of the browser or bot
}, nil, }, nil,
) )
qgen.Install.CreateTable("viewchunks_systems", "", "", qgen.Install.CreateTable("viewchunks_systems", "", "",
[]tblColumn{ []tC{
tblColumn{"count", "int", 0, false, false, "0"}, tC{"count", "int", 0, false, false, "0"},
tblColumn{"createdAt", "datetime", 0, false, false, ""}, tC{"createdAt", "datetime", 0, false, false, ""},
tblColumn{"system", "varchar", 200, false, false, ""}, // windows, android, unknown, etc. tC{"system", "varchar", 200, false, false, ""}, // windows, android, unknown, etc.
}, nil, }, nil,
) )
qgen.Install.CreateTable("viewchunks_langs", "", "", qgen.Install.CreateTable("viewchunks_langs", "", "",
[]tblColumn{ []tC{
tblColumn{"count", "int", 0, false, false, "0"}, tC{"count", "int", 0, false, false, "0"},
tblColumn{"createdAt", "datetime", 0, false, false, ""}, tC{"createdAt", "datetime", 0, false, false, ""},
tblColumn{"lang", "varchar", 200, false, false, ""}, // en, ru, etc. tC{"lang", "varchar", 200, false, false, ""}, // en, ru, etc.
}, nil, }, nil,
) )
qgen.Install.CreateTable("viewchunks_referrers", "", "", qgen.Install.CreateTable("viewchunks_referrers", "", "",
[]tblColumn{ []tC{
tblColumn{"count", "int", 0, false, false, "0"}, tC{"count", "int", 0, false, false, "0"},
tblColumn{"createdAt", "datetime", 0, false, false, ""}, tC{"createdAt", "datetime", 0, false, false, ""},
tblColumn{"domain", "varchar", 200, false, false, ""}, tC{"domain", "varchar", 200, false, false, ""},
}, nil, }, nil,
) )
qgen.Install.CreateTable("viewchunks_forums", "", "", qgen.Install.CreateTable("viewchunks_forums", "", "",
[]tblColumn{ []tC{
tblColumn{"count", "int", 0, false, false, "0"}, tC{"count", "int", 0, false, false, "0"},
tblColumn{"createdAt", "datetime", 0, false, false, ""}, tC{"createdAt", "datetime", 0, false, false, ""},
tblColumn{"forum", "int", 0, false, false, ""}, tC{"forum", "int", 0, false, false, ""},
}, nil, }, nil,
) )
qgen.Install.CreateTable("topicchunks", "", "", qgen.Install.CreateTable("topicchunks", "", "",
[]tblColumn{ []tC{
tblColumn{"count", "int", 0, false, false, "0"}, tC{"count", "int", 0, false, false, "0"},
tblColumn{"createdAt", "datetime", 0, false, false, ""}, tC{"createdAt", "datetime", 0, false, false, ""},
// TODO: Add a column for the parent forum? // TODO: Add a column for the parent forum?
}, nil, }, nil,
) )
qgen.Install.CreateTable("postchunks", "", "", qgen.Install.CreateTable("postchunks", "", "",
[]tblColumn{ []tC{
tblColumn{"count", "int", 0, false, false, "0"}, tC{"count", "int", 0, false, false, "0"},
tblColumn{"createdAt", "datetime", 0, false, false, ""}, tC{"createdAt", "datetime", 0, false, false, ""},
// TODO: Add a column for the parent topic / profile? // TODO: Add a column for the parent topic / profile?
}, nil, }, nil,
) )
qgen.Install.CreateTable("memchunks", "", "", qgen.Install.CreateTable("memchunks", "", "",
[]tblColumn{ []tC{
tblColumn{"count", "int", 0, false, false, "0"}, tC{"count", "int", 0, false, false, "0"},
tblColumn{"stack", "int", 0, false, false, "0"}, tC{"stack", "int", 0, false, false, "0"},
tblColumn{"heap", "int", 0, false, false, "0"}, tC{"heap", "int", 0, false, false, "0"},
tblColumn{"createdAt", "datetime", 0, false, false, ""}, tC{"createdAt", "datetime", 0, false, false, ""},
}, nil, }, nil,
) )
qgen.Install.CreateTable("sync", "", "", qgen.Install.CreateTable("sync", "", "",
[]tblColumn{ []tC{
tblColumn{"last_update", "datetime", 0, false, false, ""}, tC{"last_update", "datetime", 0, false, false, ""},
}, nil, }, nil,
) )
qgen.Install.CreateTable("updates", "", "", qgen.Install.CreateTable("updates", "", "",
[]tblColumn{ []tC{
tblColumn{"dbVersion", "int", 0, false, false, "0"}, tC{"dbVersion", "int", 0, false, false, "0"},
}, nil, }, nil,
) )
qgen.Install.CreateTable("meta", "", "", qgen.Install.CreateTable("meta", "", "",
[]tblColumn{ []tC{
tblColumn{"name", "varchar", 200, false, false, ""}, tC{"name", "varchar", 200, false, false, ""},
tblColumn{"value", "varchar", 200, false, false, ""}, tC{"value", "varchar", 200, false, false, ""},
}, nil, }, nil,
) )