reduce boilerplate in tables.go

This commit is contained in:
Azareal 2021-01-07 18:37:21 +10:00
parent 74193223ee
commit 1137d94d5b
1 changed files with 158 additions and 158 deletions

View File

@ -62,22 +62,22 @@ func createTables2(a qgen.Adapter, f func(table, charset, collation string, colu
createTable("users", mysqlPre, mysqlCol, createTable("users", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"uid", "int", 0, false, true, ""}, {"uid", "int", 0, false, true, ""},
ccol("name", 100, ""), ccol("name", 100, ""),
ccol("password", 100, ""), ccol("password", 100, ""),
ccol("salt", 80, "''"), ccol("salt", 80, "''"),
tC{"group", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"group", "int", 0, false, false, ""}, // TODO: Make this a foreign key
bcol("active", false), bcol("active", false),
bcol("is_super_admin", false), bcol("is_super_admin", false),
createdAt(), createdAt(),
tC{"lastActiveAt", "datetime", 0, false, false, ""}, {"lastActiveAt", "datetime", 0, false, false, ""},
ccol("session", 200, "''"), ccol("session", 200, "''"),
//ccol("authToken", 200, "''"), //ccol("authToken", 200, "''"),
ccol("last_ip", 200, "''"), ccol("last_ip", 200, "''"),
tC{"profile_comments", "int", 0, false, false, "0"}, {"profile_comments", "int", 0, false, false, "0"},
tC{"who_can_convo", "int", 0, false, false, "0"}, {"who_can_convo", "int", 0, false, false, "0"},
tC{"enable_embeds", "int", 0, false, false, "-1"}, {"enable_embeds", "int", 0, false, false, "-1"},
ccol("email", 200, "''"), ccol("email", 200, "''"),
ccol("avatar", 100, "''"), ccol("avatar", 100, "''"),
text("message"), text("message"),
@ -87,80 +87,80 @@ func createTables2(a qgen.Adapter, f func(table, charset, collation string, colu
ccol("url_name", 100, "''"), ccol("url_name", 100, "''"),
//text("pub_key"), //text("pub_key"),
tC{"level", "smallint", 0, false, false, "0"}, {"level", "smallint", 0, false, false, "0"},
tC{"score", "int", 0, false, false, "0"}, {"score", "int", 0, false, false, "0"},
tC{"posts", "int", 0, false, false, "0"}, {"posts", "int", 0, false, false, "0"},
tC{"bigposts", "int", 0, false, false, "0"}, {"bigposts", "int", 0, false, false, "0"},
tC{"megaposts", "int", 0, false, false, "0"}, {"megaposts", "int", 0, false, false, "0"},
tC{"topics", "int", 0, false, false, "0"}, {"topics", "int", 0, false, false, "0"},
tC{"liked", "int", 0, false, false, "0"}, {"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
tC{"oldestItemLikedCreatedAt", "datetime", 0, false, false, ""}, // For internal use only, semantics may change {"oldestItemLikedCreatedAt", "datetime", 0, false, false, ""}, // For internal use only, semantics may change
tC{"lastLiked", "datetime", 0, false, false, ""}, // For internal use only, semantics may change {"lastLiked", "datetime", 0, false, false, ""}, // For internal use only, semantics may change
//tC{"penalty_count","int",0,false,false,"0"}, //{"penalty_count","int",0,false,false,"0"},
tC{"temp_group", "int", 0, false, false, "0"}, // For temporary groups, set this to zero when a temporary group isn't in effect {"temp_group", "int", 0, false, false, "0"}, // For temporary groups, set this to zero when a temporary group isn't in effect
}, },
[]tK{ []tK{
tK{"uid", "primary", "", false}, {"uid", "primary", "", false},
tK{"name", "unique", "", false}, {"name", "unique", "", false},
}, },
) )
createTable("users_groups", mysqlPre, mysqlCol, createTable("users_groups", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"gid", "int", 0, false, true, ""}, {"gid", "int", 0, false, true, ""},
ccol("name", 100, ""), ccol("name", 100, ""),
text("permissions"), text("permissions"),
text("plugin_perms"), text("plugin_perms"),
bcol("is_mod", false), bcol("is_mod", false),
bcol("is_admin", false), bcol("is_admin", false),
bcol("is_banned", false), bcol("is_banned", false),
tC{"user_count", "int", 0, false, false, "0"}, // TODO: Implement this {"user_count", "int", 0, false, false, "0"}, // TODO: Implement this
ccol("tag", 50, "''"), ccol("tag", 50, "''"),
}, },
[]tK{ []tK{
tK{"gid", "primary", "", false}, {"gid", "primary", "", false},
}, },
) )
createTable("users_groups_promotions", mysqlPre, mysqlCol, createTable("users_groups_promotions", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"pid", "int", 0, false, true, ""}, {"pid", "int", 0, false, true, ""},
tC{"from_gid", "int", 0, false, false, ""}, {"from_gid", "int", 0, false, false, ""},
tC{"to_gid", "int", 0, false, false, ""}, {"to_gid", "int", 0, false, false, ""},
bcol("two_way", false), // If a user no longer meets the requirements for this promotion then they will be demoted if this flag is set bcol("two_way", false), // If a user no longer meets the requirements for this promotion then they will be demoted if this flag is set
// Requirements // Requirements
tC{"level", "int", 0, false, false, ""}, {"level", "int", 0, false, false, ""},
tC{"posts", "int", 0, false, false, "0"}, {"posts", "int", 0, false, false, "0"},
tC{"minTime", "int", 0, false, false, ""}, // How long someone needs to have been in their current group before being promoted {"minTime", "int", 0, false, false, ""}, // How long someone needs to have been in their current group before being promoted
tC{"registeredFor", "int", 0, false, false, "0"}, // minutes {"registeredFor", "int", 0, false, false, "0"}, // minutes
}, },
[]tK{ []tK{
tK{"pid", "primary", "", false}, {"pid", "primary", "", false},
}, },
) )
/* /*
createTable("users_groups_promotions_scheduled","","", createTable("users_groups_promotions_scheduled","","",
[]tC{ []tC{
tC{"prid","int",0,false,false,""}, {"prid","int",0,false,false,""},
tC{"uid","int",0,false,false,""}, {"uid","int",0,false,false,""},
tC{"runAt","datetime",0,false,false,""}, {"runAt","datetime",0,false,false,""},
}, },
[]tblKey{ []tK{
// TODO: Test to see that the compound primary key works // TODO: Test to see that the compound primary key works
tblKey{"prid,uid", "primary", "", false}, {"prid,uid", "primary", "", false},
}, },
) )
*/ */
createTable("users_2fa_keys", mysqlPre, mysqlCol, createTable("users_2fa_keys", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"uid", "int", 0, false, false, ""}, {"uid", "int", 0, false, false, ""},
ccol("secret", 100, ""), ccol("secret", 100, ""),
ccol("scratch1", 50, ""), ccol("scratch1", 50, ""),
ccol("scratch2", 50, ""), ccol("scratch2", 50, ""),
@ -170,10 +170,10 @@ func createTables2(a qgen.Adapter, f func(table, charset, collation string, colu
ccol("scratch6", 50, ""), ccol("scratch6", 50, ""),
ccol("scratch7", 50, ""), ccol("scratch7", 50, ""),
ccol("scratch8", 50, ""), ccol("scratch8", 50, ""),
tC{"createdAt", "createdAt", 0, false, false, ""}, {"createdAt", "createdAt", 0, false, false, ""},
}, },
[]tblKey{ []tblKey{
tblKey{"uid", "primary", "", false}, {"uid", "primary", "", false},
}, },
) )
@ -185,8 +185,8 @@ func createTables2(a qgen.Adapter, f func(table, charset, collation string, colu
// 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.
/*createTable("users_penalties","","", /*createTable("users_penalties","","",
[]tC{ []tC{
tC{"uid","int",0,false,false,""}, {"uid","int",0,false,false,""},
tC{"element_id","int",0,false,false,""}, {"element_id","int",0,false,false,""},
ccol("element_type",50,""), //forum, profile?, and social_group. Leave blank for global. ccol("element_type",50,""), //forum, profile?, and social_group. Leave blank for global.
text("overrides","{}"), text("overrides","{}"),
@ -195,40 +195,40 @@ func createTables2(a qgen.Adapter, f func(table, charset, collation string, colu
bcol("no_avatar",false), // Coming Soon. Should this be a perm override instead? bcol("no_avatar",false), // 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?
//tC{"posts_per_hour","int",0,false,false,"0"}, //{"posts_per_hour","int",0,false,false,"0"},
//tC{"topics_per_hour","int",0,false,false,"0"}, //{"topics_per_hour","int",0,false,false,"0"},
//tC{"posts_count","int",0,false,false,"0"}, //{"posts_count","int",0,false,false,"0"},
//tC{"topic_count","int",0,false,false,"0"}, //{"topic_count","int",0,false,false,"0"},
//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. //{"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{"issued_by","int",0,false,false,""}, {"issued_by","int",0,false,false,""},
createdAt("issued_at"), createdAt("issued_at"),
tC{"expires_at","datetime",0,false,false,""}, {"expires_at","datetime",0,false,false,""},
}, nil, }, nil,
)*/ )*/
createTable("users_groups_scheduler", "", "", createTable("users_groups_scheduler", "", "",
[]tC{ []tC{
tC{"uid", "int", 0, false, false, ""}, {"uid", "int", 0, false, false, ""},
tC{"set_group", "int", 0, false, false, ""}, {"set_group", "int", 0, false, false, ""},
tC{"issued_by", "int", 0, false, false, ""}, {"issued_by", "int", 0, false, false, ""},
createdAt("issued_at"), createdAt("issued_at"),
tC{"revert_at", "datetime", 0, false, false, ""}, {"revert_at", "datetime", 0, false, false, ""},
tC{"temporary", "boolean", 0, false, false, ""}, // special case for permanent bans to do the necessary bookkeeping, might be removed in the future {"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}, {"uid", "primary", "", false},
}, },
) )
// 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?
createTable("users_avatar_queue", "", "", createTable("users_avatar_queue", "", "",
[]tC{ []tC{
tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
}, },
[]tblKey{ []tblKey{
tblKey{"uid", "primary", "", false}, {"uid", "primary", "", false},
}, },
) )
@ -237,7 +237,7 @@ func createTables2(a qgen.Adapter, f func(table, charset, collation string, colu
createTable("emails", "", "", createTable("emails", "", "",
[]tC{ []tC{
ccol("email", 200, ""), ccol("email", 200, ""),
tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
bcol("validated", false), bcol("validated", false),
ccol("token", 200, "''"), ccol("token", 200, "''"),
}, nil, }, nil,
@ -251,7 +251,7 @@ func createTables2(a qgen.Adapter, f func(table, charset, collation string, colu
bcol("gtld", false), bcol("gtld", false),
}, },
[]tK{ []tK{
tK{"domain", "primary"}, {"domain", "primary"},
}, },
) )
*/ */
@ -260,8 +260,8 @@ func createTables2(a qgen.Adapter, f func(table, charset, collation string, colu
createTable("password_resets", "", "", createTable("password_resets", "", "",
[]tC{ []tC{
ccol("email", 200, ""), ccol("email", 200, ""),
tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
ccol("validated", 200, ""), // Token given once the one-use token is consumed, used to prevent multiple people consuming the same one-use token ccol("validated", 200, ""), // Token given once the one-use token is consumed, used to prevent multiple people consuming the same one-use token
ccol("token", 200, ""), ccol("token", 200, ""),
createdAt(), createdAt(),
}, nil, }, nil,
@ -269,159 +269,159 @@ func createTables2(a qgen.Adapter, f func(table, charset, collation string, colu
createTable("forums", mysqlPre, mysqlCol, createTable("forums", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"fid", "int", 0, false, true, ""}, {"fid", "int", 0, false, true, ""},
ccol("name", 100, ""), ccol("name", 100, ""),
ccol("desc", 200, ""), ccol("desc", 200, ""),
ccol("tmpl", 200, "''"), ccol("tmpl", 200, "''"),
bcol("active", true), bcol("active", true),
tC{"order", "int", 0, false, false, "0"}, {"order", "int", 0, false, false, "0"},
tC{"topicCount", "int", 0, false, false, "0"}, {"topicCount", "int", 0, false, false, "0"},
ccol("preset", 100, "''"), ccol("preset", 100, "''"),
tC{"parentID", "int", 0, false, false, "0"}, {"parentID", "int", 0, false, false, "0"},
ccol("parentType", 50, "''"), ccol("parentType", 50, "''"),
tC{"lastTopicID", "int", 0, false, false, "0"}, {"lastTopicID", "int", 0, false, false, "0"},
tC{"lastReplyerID", "int", 0, false, false, "0"}, {"lastReplyerID", "int", 0, false, false, "0"},
}, },
[]tblKey{ []tblKey{
tblKey{"fid", "primary", "", false}, {"fid", "primary", "", false},
}, },
) )
createTable("forums_permissions", "", "", createTable("forums_permissions", "", "",
[]tC{ []tC{
tC{"fid", "int", 0, false, false, ""}, {"fid", "int", 0, false, false, ""},
tC{"gid", "int", 0, false, false, ""}, {"gid", "int", 0, false, false, ""},
ccol("preset", 100, "''"), ccol("preset", 100, "''"),
text("permissions", "{}"), text("permissions", "{}"),
}, },
[]tblKey{ []tblKey{
// TODO: Test to see that the compound primary key works // TODO: Test to see that the compound primary key works
tblKey{"fid,gid", "primary", "", false}, {"fid,gid", "primary", "", false},
}, },
) )
createTable("topics", mysqlPre, mysqlCol, createTable("topics", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"tid", "int", 0, false, true, ""}, {"tid", "int", 0, false, true, ""},
ccol("title", 100, ""), // TODO: Increase the max length to 200? ccol("title", 100, ""), // TODO: Increase the max length to 200?
text("content"), text("content"),
text("parsed_content"), text("parsed_content"),
createdAt(), createdAt(),
tC{"lastReplyAt", "datetime", 0, false, false, ""}, {"lastReplyAt", "datetime", 0, false, false, ""},
tC{"lastReplyBy", "int", 0, false, false, ""}, {"lastReplyBy", "int", 0, false, false, ""},
tC{"lastReplyID", "int", 0, false, false, "0"}, {"lastReplyID", "int", 0, false, false, "0"},
tC{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key
bcol("is_closed", false), bcol("is_closed", false),
bcol("sticky", false), bcol("sticky", false),
// TODO: Add an index for this // TODO: Add an index for this
tC{"parentID", "int", 0, false, false, "2"}, {"parentID", "int", 0, false, false, "2"},
ccol("ip", 200, "''"), ccol("ip", 200, "''"),
tC{"postCount", "int", 0, false, false, "1"}, {"postCount", "int", 0, false, false, "1"},
tC{"likeCount", "int", 0, false, false, "0"}, {"likeCount", "int", 0, false, false, "0"},
tC{"attachCount", "int", 0, false, false, "0"}, {"attachCount", "int", 0, false, false, "0"},
tC{"words", "int", 0, false, false, "0"}, {"words", "int", 0, false, false, "0"},
tC{"views", "int", 0, false, false, "0"}, {"views", "int", 0, false, false, "0"},
//tC{"dayViews", "int", 0, false, false, "0"}, //{"dayViews", "int", 0, false, false, "0"},
tC{"weekEvenViews", "int", 0, false, false, "0"}, {"weekEvenViews", "int", 0, false, false, "0"},
tC{"weekOddViews", "int", 0, false, false, "0"}, {"weekOddViews", "int", 0, false, false, "0"},
///tC{"weekViews", "int", 0, false, false, "0"}, ///{"weekViews", "int", 0, false, false, "0"},
///tC{"lastWeekViews", "int", 0, false, false, "0"}, ///{"lastWeekViews", "int", 0, false, false, "0"},
//tC{"monthViews", "int", 0, false, false, "0"}, //{"monthViews", "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?
//tC{"lastMonth", "datetime", 0, false, false, ""}, //{"lastMonth", "datetime", 0, false, false, ""},
ccol("css_class", 100, "''"), ccol("css_class", 100, "''"),
tC{"poll", "int", 0, false, false, "0"}, {"poll", "int", 0, false, false, "0"},
ccol("data", 200, "''"), ccol("data", 200, "''"),
}, },
[]tK{ []tK{
tK{"tid", "primary", "", false}, {"tid", "primary", "", false},
tK{"title", "fulltext", "", false}, {"title", "fulltext", "", false},
tK{"content", "fulltext", "", false}, {"content", "fulltext", "", false},
}, },
) )
createTable("replies", mysqlPre, mysqlCol, createTable("replies", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"rid", "int", 0, false, true, ""}, // TODO: Rename to replyID? {"rid", "int", 0, false, true, ""}, // TODO: Rename to replyID?
tC{"tid", "int", 0, false, false, ""}, // TODO: Rename to topicID? {"tid", "int", 0, false, false, ""}, // TODO: Rename to topicID?
text("content"), text("content"),
text("parsed_content"), text("parsed_content"),
createdAt(), createdAt(),
tC{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tC{"lastEdit", "int", 0, false, false, "0"}, {"lastEdit", "int", 0, false, false, "0"},
tC{"lastEditBy", "int", 0, false, false, "0"}, {"lastEditBy", "int", 0, false, false, "0"},
tC{"lastUpdated", "datetime", 0, false, false, ""}, {"lastUpdated", "datetime", 0, false, false, ""},
ccol("ip", 200, "''"), ccol("ip", 200, "''"),
tC{"likeCount", "int", 0, false, false, "0"}, {"likeCount", "int", 0, false, false, "0"},
tC{"attachCount", "int", 0, false, false, "0"}, {"attachCount", "int", 0, false, false, "0"},
tC{"words", "int", 0, false, false, "1"}, // ? - replies has a default of 1 and topics has 0? why? {"words", "int", 0, false, false, "1"}, // ? - replies has a default of 1 and topics has 0? why?
ccol("actionType", 20, "''"), ccol("actionType", 20, "''"),
tC{"poll", "int", 0, false, false, "0"}, {"poll", "int", 0, false, false, "0"},
}, },
[]tK{ []tK{
tK{"rid", "primary", "", false}, {"rid", "primary", "", false},
tK{"content", "fulltext", "", false}, {"content", "fulltext", "", false},
}, },
) )
createTable("attachments", mysqlPre, mysqlCol, createTable("attachments", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"attachID", "int", 0, false, true, ""}, {"attachID", "int", 0, false, true, ""},
tC{"sectionID", "int", 0, false, false, "0"}, {"sectionID", "int", 0, false, false, "0"},
ccol("sectionTable", 200, "forums"), ccol("sectionTable", 200, "forums"),
tC{"originID", "int", 0, false, false, ""}, {"originID", "int", 0, false, false, ""},
ccol("originTable", 200, "replies"), ccol("originTable", 200, "replies"),
tC{"uploadedBy", "int", 0, false, false, ""}, // TODO; Make this a foreign key {"uploadedBy", "int", 0, false, false, ""}, // TODO; Make this a foreign key
ccol("path", 200, ""), ccol("path", 200, ""),
ccol("extra", 200, ""), ccol("extra", 200, ""),
}, },
[]tblKey{ []tblKey{
tblKey{"attachID", "primary", "", false}, {"attachID", "primary", "", false},
}, },
) )
createTable("revisions", mysqlPre, mysqlCol, createTable("revisions", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"reviseID", "int", 0, false, true, ""}, {"reviseID", "int", 0, false, true, ""},
text("content"), text("content"),
tC{"contentID", "int", 0, false, false, ""}, {"contentID", "int", 0, false, false, ""},
ccol("contentType", 100, "replies"), ccol("contentType", 100, "replies"),
createdAt(), createdAt(),
// TODO: Add a createdBy column? // TODO: Add a createdBy column?
}, },
[]tblKey{ []tblKey{
tblKey{"reviseID", "primary", "", false}, {"reviseID", "primary", "", false},
}, },
) )
createTable("polls", mysqlPre, mysqlCol, createTable("polls", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"pollID", "int", 0, false, true, ""}, {"pollID", "int", 0, false, true, ""},
tC{"parentID", "int", 0, false, false, "0"}, {"parentID", "int", 0, false, false, "0"},
ccol("parentTable", 100, "topics"), // topics, replies ccol("parentTable", 100, "topics"), // topics, replies
tC{"type", "int", 0, false, false, "0"}, {"type", "int", 0, false, false, "0"},
tC{"options", "json", 0, false, false, ""}, {"options", "json", 0, false, false, ""},
tC{"votes", "int", 0, false, false, "0"}, {"votes", "int", 0, false, false, "0"},
}, },
[]tblKey{ []tblKey{
tblKey{"pollID", "primary", "", false}, {"pollID", "primary", "", false},
}, },
) )
createTable("polls_options", "", "", createTable("polls_options", "", "",
[]tC{ []tC{
tC{"pollID", "int", 0, false, false, ""}, {"pollID", "int", 0, false, false, ""},
tC{"option", "int", 0, false, false, "0"}, {"option", "int", 0, false, false, "0"},
tC{"votes", "int", 0, false, false, "0"}, {"votes", "int", 0, false, false, "0"},
}, nil, }, nil,
) )
createTable("polls_votes", mysqlPre, mysqlCol, createTable("polls_votes", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"pollID", "int", 0, false, false, ""}, {"pollID", "int", 0, false, false, ""},
tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tC{"option", "int", 0, false, false, "0"}, {"option", "int", 0, false, false, "0"},
createdAt("castAt"), createdAt("castAt"),
ccol("ip", 200, "''"), ccol("ip", 200, "''"),
}, nil, }, nil,
@ -429,105 +429,105 @@ func createTables2(a qgen.Adapter, f func(table, charset, collation string, colu
createTable("users_replies", mysqlPre, mysqlCol, createTable("users_replies", mysqlPre, mysqlCol,
[]tC{ []tC{
tC{"rid", "int", 0, false, true, ""}, {"rid", "int", 0, false, true, ""},
tC{"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
text("content"), text("content"),
text("parsed_content"), text("parsed_content"),
createdAt(), createdAt(),
tC{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tC{"lastEdit", "int", 0, false, false, "0"}, {"lastEdit", "int", 0, false, false, "0"},
tC{"lastEditBy", "int", 0, false, false, "0"}, {"lastEditBy", "int", 0, false, false, "0"},
ccol("ip", 200, "''"), ccol("ip", 200, "''"),
}, },
[]tblKey{ []tblKey{
tblKey{"rid", "primary", "", false}, {"rid", "primary", "", false},
}, },
) )
createTable("likes", "", "", createTable("likes", "", "",
[]tC{ []tC{
tC{"weight", "tinyint", 0, false, false, "1"}, {"weight", "tinyint", 0, false, false, "1"},
tC{"targetItem", "int", 0, false, false, ""}, {"targetItem", "int", 0, false, false, ""},
ccol("targetType", 50, "replies"), ccol("targetType", 50, "replies"),
tC{"sentBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"sentBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key
createdAt(), createdAt(),
tC{"recalc", "tinyint", 0, false, false, "0"}, {"recalc", "tinyint", 0, false, false, "0"},
}, nil, }, nil,
) )
//columns("participants, createdBy, createdAt, lastReplyBy, lastReplyAt").Where("cid = ?") //columns("participants, createdBy, createdAt, lastReplyBy, lastReplyAt").Where("cid = ?")
createTable("conversations", "", "", createTable("conversations", "", "",
[]tC{ []tC{
tC{"cid", "int", 0, false, true, ""}, {"cid", "int", 0, false, true, ""},
tC{"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key
createdAt(), createdAt(),
tC{"lastReplyAt", "datetime", 0, false, false, ""}, {"lastReplyAt", "datetime", 0, false, false, ""},
tC{"lastReplyBy", "int", 0, false, false, ""}, {"lastReplyBy", "int", 0, false, false, ""},
}, },
[]tblKey{ []tblKey{
tblKey{"cid", "primary", "", false}, {"cid", "primary", "", false},
}, },
) )
createTable("conversations_posts", "", "", createTable("conversations_posts", "", "",
[]tC{ []tC{
tC{"pid", "int", 0, false, true, ""}, {"pid", "int", 0, false, true, ""},
tC{"cid", "int", 0, false, false, ""}, {"cid", "int", 0, false, false, ""},
tC{"createdBy", "int", 0, false, false, ""}, {"createdBy", "int", 0, false, false, ""},
ccol("body", 50, ""), ccol("body", 50, ""),
ccol("post", 50, "''"), ccol("post", 50, "''"),
}, },
[]tblKey{ []tblKey{
tblKey{"pid", "primary", "", false}, {"pid", "primary", "", false},
}, },
) )
createTable("conversations_participants", "", "", createTable("conversations_participants", "", "",
[]tC{ []tC{
tC{"uid", "int", 0, false, false, ""}, {"uid", "int", 0, false, false, ""},
tC{"cid", "int", 0, false, false, ""}, {"cid", "int", 0, false, false, ""},
}, nil, }, nil,
) )
/* /*
createTable("users_friends", "", "", createTable("users_friends", "", "",
[]tC{ []tC{
tC{"uid", "int", 0, false, false, ""}, {"uid", "int", 0, false, false, ""},
tC{"uid2", "int", 0, false, false, ""}, {"uid2", "int", 0, false, false, ""},
}, nil, }, nil,
) )
createTable("users_friends_invites", "", "", createTable("users_friends_invites", "", "",
[]tC{ []tC{
tC{"requester", "int", 0, false, false, ""}, {"requester", "int", 0, false, false, ""},
tC{"target", "int", 0, false, false, ""}, {"target", "int", 0, false, false, ""},
}, nil, }, nil,
) )
*/ */
createTable("users_blocks", "", "", createTable("users_blocks", "", "",
[]tC{ []tC{
tC{"blocker", "int", 0, false, false, ""}, {"blocker", "int", 0, false, false, ""},
tC{"blockedUser", "int", 0, false, false, ""}, {"blockedUser", "int", 0, false, false, ""},
}, nil, }, nil,
) )
createTable("activity_stream_matches", "", "", createTable("activity_stream_matches", "", "",
[]tC{ []tC{
tC{"watcher", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"watcher", "int", 0, false, false, ""}, // TODO: Make this a foreign key
tC{"asid", "int", 0, false, false, ""}, // TODO: Make this a foreign key {"asid", "int", 0, false, false, ""}, // TODO: Make this a foreign key
}, },
[]tblKey{ []tblKey{
tblKey{"asid,asid", "foreign", "activity_stream", true}, {"asid,asid", "foreign", "activity_stream", true},
}, },
) )
createTable("activity_stream", "", "", createTable("activity_stream", "", "",
[]tC{ []tC{
tC{"asid", "int", 0, false, true, ""}, {"asid", "int", 0, false, true, ""},
tC{"actor", "int", 0, false, false, ""}, /* the one doing the act */ // TODO: Make this a foreign key {"actor", "int", 0, false, false, ""}, /* the one doing the act */ // TODO: Make this a foreign key
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 */ {"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 */
ccol("event", 50, ""), /* 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 */ ccol("event", 50, ""), /* 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 */
ccol("elementType", 50, ""), /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */ ccol("elementType", 50, ""), /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */
// replacement for elementType // replacement for elementType
tC{"elementTable", "int", 0, false, false, "0"}, tC{"elementTable", "int", 0, false, false, "0"},