2017-10-16 07:32:58 +00:00
package main
2019-10-07 21:22:33 +00:00
import qgen "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"
2020-07-14 21:50:29 +00:00
var tables [ ] string
2018-12-27 05:42:41 +00:00
type tblColumn = qgen . DBTableColumn
2019-07-26 23:18:32 +00:00
type tC = tblColumn
2018-12-27 05:42:41 +00:00
type tblKey = qgen . DBTableKey
2020-03-21 08:55:15 +00:00
func createTables ( a qgen . Adapter ) error {
2020-07-14 21:50:29 +00:00
tables = nil
2020-03-21 08:55:15 +00:00
f := func ( table , charset , collation string , cols [ ] tC , keys [ ] tblKey ) error {
2020-07-14 21:50:29 +00:00
tables = append ( tables , table )
2020-03-21 08:55:15 +00:00
return qgen . Install . CreateTable ( table , charset , collation , cols , keys )
}
return createTables2 ( a , f )
}
func createTables2 ( a qgen . Adapter , f func ( table , charset , collation string , columns [ ] tC , keys [ ] tblKey ) error ) ( err error ) {
createTable := func ( table , charset , collation string , cols [ ] tC , keys [ ] tblKey ) {
2019-10-06 22:20:37 +00:00
if err != nil {
return
}
2020-03-21 08:55:15 +00:00
err = f ( table , charset , collation , cols , keys )
2019-10-06 22:20:37 +00:00
}
2020-07-14 21:50:29 +00:00
bcol := func ( col string , val bool ) qgen . DBTableColumn {
if val {
return tC { col , "boolean" , 0 , false , false , "1" }
}
return tC { col , "boolean" , 0 , false , false , "0" }
}
ccol := func ( col string , size int , sdefault string ) qgen . DBTableColumn {
return tC { col , "varchar" , size , false , false , sdefault }
}
text := func ( params ... string ) qgen . DBTableColumn {
if len ( params ) == 0 {
return tC { "" , "text" , 0 , false , false , "" }
}
col , sdefault := params [ 0 ] , ""
if len ( params ) > 1 {
sdefault = params [ 1 ]
if sdefault == "" {
sdefault = "''"
}
}
return tC { col , "text" , 0 , false , false , sdefault }
}
createdAt := func ( coll ... string ) qgen . DBTableColumn {
var col string
if len ( coll ) > 0 {
col = coll [ 0 ]
}
if col == "" {
col = "createdAt"
}
return tC { col , "createdAt" , 0 , false , false , "" }
}
2019-10-06 22:20:37 +00:00
createTable ( "users" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "uid" , "int" , 0 , false , true , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "name" , 100 , "" ) ,
ccol ( "password" , 100 , "" ) ,
2019-07-26 23:18:32 +00:00
2020-07-14 21:50:29 +00:00
ccol ( "salt" , 80 , "''" ) ,
2021-01-07 08:37:21 +00:00
{ "group" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
2020-07-14 21:50:29 +00:00
bcol ( "active" , false ) ,
bcol ( "is_super_admin" , false ) ,
createdAt ( ) ,
2021-01-07 08:37:21 +00:00
{ "lastActiveAt" , "datetime" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "session" , 200 , "''" ) ,
//ccol("authToken", 200, "''"),
ccol ( "last_ip" , 200 , "''" ) ,
2021-01-07 08:37:21 +00:00
{ "profile_comments" , "int" , 0 , false , false , "0" } ,
{ "who_can_convo" , "int" , 0 , false , false , "0" } ,
{ "enable_embeds" , "int" , 0 , false , false , "-1" } ,
2020-07-14 21:50:29 +00:00
ccol ( "email" , 200 , "''" ) ,
ccol ( "avatar" , 100 , "''" ) ,
text ( "message" ) ,
2019-12-08 03:40:56 +00:00
// TODO: Drop these columns?
2020-07-14 21:50:29 +00:00
ccol ( "url_prefix" , 20 , "''" ) ,
ccol ( "url_name" , 100 , "''" ) ,
//text("pub_key"),
Cascade delete attachments properly.
Cascade delete replied to topic events for replies properly.
Cascade delete likes on topic posts properly.
Cascade delete replies and their children properly.
Recalculate user stats properly when items are deleted.
Users can now unlike topic opening posts.
Add a recalculator to fix abnormalities across upgrades.
Try fixing a last_ip daily update bug.
Add Existable interface.
Add Delete method to LikeStore.
Add Each, Exists, Create, CountUser, CountMegaUser and CountBigUser methods to ReplyStore.
Add CountUser, CountMegaUser, CountBigUser methods to TopicStore.
Add Each method to UserStore.
Add Add, Delete and DeleteResource methods to SubscriptionStore.
Add Delete, DeleteByParams, DeleteByParamsExtra and AidsByParamsExtra methods to ActivityStream.
Add Exists method to ProfileReplyStore.
Add DropColumn, RenameColumn and ChangeColumn to the database adapters.
Shorten ipaddress column names to ip.
- topics table.
- replies table
- users_replies table.
- polls_votes table.
Add extra column to activity_stream table.
Fix an issue upgrading sites to MariaDB 10.3 from older versions of Gosora. Please report any other issues you find.
You need to run the updater / patcher for this commit.
2020-01-31 07:22:08 +00:00
2021-01-07 08:37:21 +00:00
{ "level" , "smallint" , 0 , false , false , "0" } ,
{ "score" , "int" , 0 , false , false , "0" } ,
{ "posts" , "int" , 0 , false , false , "0" } ,
{ "bigposts" , "int" , 0 , false , false , "0" } ,
{ "megaposts" , "int" , 0 , false , false , "0" } ,
{ "topics" , "int" , 0 , false , false , "0" } ,
{ "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
2021-01-07 08:37:21 +00:00
{ "oldestItemLikedCreatedAt" , "datetime" , 0 , false , false , "" } , // For internal use only, semantics may change
{ "lastLiked" , "datetime" , 0 , false , false , "" } , // For internal use only, semantics may change
2018-03-31 05:25:27 +00:00
2021-01-07 08:37:21 +00:00
//{"penalty_count","int",0,false,false,"0"},
{ "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
} ,
2020-07-14 21:50:29 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "uid" , "primary" , "" , false } ,
{ "name" , "unique" , "" , false } ,
2017-10-16 07:32:58 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "users_groups" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "gid" , "int" , 0 , false , true , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "name" , 100 , "" ) ,
text ( "permissions" ) ,
text ( "plugin_perms" ) ,
bcol ( "is_mod" , false ) ,
bcol ( "is_admin" , false ) ,
bcol ( "is_banned" , false ) ,
2021-01-07 08:37:21 +00:00
{ "user_count" , "int" , 0 , false , false , "0" } , // TODO: Implement this
2019-07-26 23:18:32 +00:00
2020-07-14 21:50:29 +00:00
ccol ( "tag" , 50 , "''" ) ,
2017-11-12 05:25:04 +00:00
} ,
2020-07-14 21:50:29 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "gid" , "primary" , "" , false } ,
2017-10-16 07:32:58 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "users_groups_promotions" , mysqlPre , mysqlCol ,
2019-09-29 04:56:39 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "pid" , "int" , 0 , false , true , "" } ,
{ "from_gid" , "int" , 0 , false , false , "" } ,
{ "to_gid" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
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
2019-09-29 04:56:39 +00:00
// Requirements
2021-01-07 08:37:21 +00:00
{ "level" , "int" , 0 , false , false , "" } ,
{ "posts" , "int" , 0 , false , false , "0" } ,
{ "minTime" , "int" , 0 , false , false , "" } , // How long someone needs to have been in their current group before being promoted
{ "registeredFor" , "int" , 0 , false , false , "0" } , // minutes
2019-09-29 04:56:39 +00:00
} ,
2020-07-14 21:50:29 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "pid" , "primary" , "" , false } ,
2019-09-29 04:56:39 +00:00
} ,
)
2020-02-09 10:00:08 +00:00
/ *
createTable ( "users_groups_promotions_scheduled" , "" , "" ,
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "prid" , "int" , 0 , false , false , "" } ,
{ "uid" , "int" , 0 , false , false , "" } ,
{ "runAt" , "datetime" , 0 , false , false , "" } ,
2020-02-09 10:00:08 +00:00
} ,
2021-01-07 08:37:21 +00:00
[ ] tK {
2020-02-09 10:00:08 +00:00
// TODO: Test to see that the compound primary key works
2021-01-07 08:37:21 +00:00
{ "prid,uid" , "primary" , "" , false } ,
2020-02-09 10:00:08 +00:00
} ,
)
* /
2019-10-06 22:20:37 +00:00
createTable ( "users_2fa_keys" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "uid" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "secret" , 100 , "" ) ,
ccol ( "scratch1" , 50 , "" ) ,
ccol ( "scratch2" , 50 , "" ) ,
ccol ( "scratch3" , 50 , "" ) ,
ccol ( "scratch4" , 50 , "" ) ,
ccol ( "scratch5" , 50 , "" ) ,
ccol ( "scratch6" , 50 , "" ) ,
ccol ( "scratch7" , 50 , "" ) ,
ccol ( "scratch8" , 50 , "" ) ,
2021-01-07 08:37:21 +00:00
{ "createdAt" , "createdAt" , 0 , false , false , "" } ,
2018-06-17 07:28:18 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "uid" , "primary" , "" , false } ,
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.
2019-10-06 22:20:37 +00:00
/ * createTable ( "users_penalties" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "uid" , "int" , 0 , false , false , "" } ,
{ "element_id" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "element_type" , 50 , "" ) , //forum, profile?, and social_group. Leave blank for global.
text ( "overrides" , "{}" ) ,
2017-10-16 07:32:58 +00:00
2020-07-14 21:50:29 +00:00
bcol ( "mod_queue" , false ) ,
bcol ( "shadow_ban" , false ) ,
bcol ( "no_avatar" , false ) , // 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?
2021-01-07 08:37:21 +00:00
//{"posts_per_hour","int",0,false,false,"0"},
//{"topics_per_hour","int",0,false,false,"0"},
//{"posts_count","int",0,false,false,"0"},
//{"topic_count","int",0,false,false,"0"},
//{"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.
2019-07-26 23:18:32 +00:00
2021-01-07 08:37:21 +00:00
{ "issued_by" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
createdAt ( "issued_at" ) ,
2021-01-07 08:37:21 +00:00
{ "expires_at" , "datetime" , 0 , false , false , "" } ,
2019-01-21 12:27:59 +00:00
} , nil ,
2017-10-16 07:32:58 +00:00
) * /
2019-10-06 22:20:37 +00:00
createTable ( "users_groups_scheduler" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "uid" , "int" , 0 , false , false , "" } ,
{ "set_group" , "int" , 0 , false , false , "" } ,
2017-10-16 07:32:58 +00:00
2021-01-07 08:37:21 +00:00
{ "issued_by" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
createdAt ( "issued_at" ) ,
2021-01-07 08:37:21 +00:00
{ "revert_at" , "datetime" , 0 , false , false , "" } ,
{ "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
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "uid" , "primary" , "" , false } ,
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?
2019-10-06 22:20:37 +00:00
createTable ( "users_avatar_queue" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "uid" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
2018-07-28 12:52:23 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "uid" , "primary" , "" , false } ,
2018-07-28 12:52:23 +00:00
} ,
)
// TODO: Should we add a users prefix to this table to fit the "unofficial convention"?
2019-11-10 02:37:53 +00:00
// TODO: Add an autoincrement key?
2019-10-06 22:20:37 +00:00
createTable ( "emails" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2020-07-14 21:50:29 +00:00
ccol ( "email" , 200 , "" ) ,
2021-01-07 08:37:21 +00:00
{ "uid" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
2020-07-14 21:50:29 +00:00
bcol ( "validated" , false ) ,
ccol ( "token" , 200 , "''" ) ,
2019-01-21 12:27:59 +00:00
} , nil ,
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?
/ *
2019-10-06 22:20:37 +00:00
createTable ( "email_domain_blacklist" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2020-07-14 21:50:29 +00:00
ccol ( "domain" , 200 , "" ) ,
bcol ( "gtld" , false ) ,
2018-07-05 09:54:01 +00:00
} ,
2020-07-14 21:50:29 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "domain" , "primary" } ,
2018-07-05 09:54:01 +00:00
} ,
)
* /
2019-01-21 12:27:59 +00:00
// TODO: Implement password resets
2019-10-06 22:20:37 +00:00
createTable ( "password_resets" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2020-07-14 21:50:29 +00:00
ccol ( "email" , 200 , "" ) ,
2021-01-07 08:37:21 +00:00
{ "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
2020-07-14 21:50:29 +00:00
ccol ( "token" , 200 , "" ) ,
createdAt ( ) ,
2019-03-11 08:47:45 +00:00
} , nil ,
)
2019-01-21 12:27:59 +00:00
2019-10-06 22:20:37 +00:00
createTable ( "forums" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "fid" , "int" , 0 , false , true , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "name" , 100 , "" ) ,
ccol ( "desc" , 200 , "" ) ,
ccol ( "tmpl" , 200 , "''" ) ,
bcol ( "active" , true ) ,
2021-01-07 08:37:21 +00:00
{ "order" , "int" , 0 , false , false , "0" } ,
{ "topicCount" , "int" , 0 , false , false , "0" } ,
2020-07-14 21:50:29 +00:00
ccol ( "preset" , 100 , "''" ) ,
2021-01-07 08:37:21 +00:00
{ "parentID" , "int" , 0 , false , false , "0" } ,
2020-07-14 21:50:29 +00:00
ccol ( "parentType" , 50 , "''" ) ,
2021-01-07 08:37:21 +00:00
{ "lastTopicID" , "int" , 0 , false , false , "0" } ,
{ "lastReplyerID" , "int" , 0 , false , false , "0" } ,
2017-11-12 05:25:04 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "fid" , "primary" , "" , false } ,
2017-10-16 07:32:58 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "forums_permissions" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "fid" , "int" , 0 , false , false , "" } ,
{ "gid" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "preset" , 100 , "''" ) ,
text ( "permissions" , "{}" ) ,
2017-10-16 07:32:58 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2017-10-16 07:32:58 +00:00
// TODO: Test to see that the compound primary key works
2021-01-07 08:37:21 +00:00
{ "fid,gid" , "primary" , "" , false } ,
2018-12-27 05:42:41 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "topics" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "tid" , "int" , 0 , false , true , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "title" , 100 , "" ) , // TODO: Increase the max length to 200?
text ( "content" ) ,
text ( "parsed_content" ) ,
createdAt ( ) ,
2021-01-07 08:37:21 +00:00
{ "lastReplyAt" , "datetime" , 0 , false , false , "" } ,
{ "lastReplyBy" , "int" , 0 , false , false , "" } ,
{ "lastReplyID" , "int" , 0 , false , false , "0" } ,
{ "createdBy" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
2020-07-14 21:50:29 +00:00
bcol ( "is_closed" , false ) ,
bcol ( "sticky" , false ) ,
2018-10-06 13:14:11 +00:00
// TODO: Add an index for this
2021-01-07 08:37:21 +00:00
{ "parentID" , "int" , 0 , false , false , "2" } ,
2020-07-14 21:50:29 +00:00
ccol ( "ip" , 200 , "''" ) ,
2021-01-07 08:37:21 +00:00
{ "postCount" , "int" , 0 , false , false , "1" } ,
{ "likeCount" , "int" , 0 , false , false , "0" } ,
{ "attachCount" , "int" , 0 , false , false , "0" } ,
{ "words" , "int" , 0 , false , false , "0" } ,
{ "views" , "int" , 0 , false , false , "0" } ,
//{"dayViews", "int", 0, false, false, "0"},
{ "weekEvenViews" , "int" , 0 , false , false , "0" } ,
{ "weekOddViews" , "int" , 0 , false , false , "0" } ,
///{"weekViews", "int", 0, false, false, "0"},
///{"lastWeekViews", "int", 0, false, false, "0"},
//{"monthViews", "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?
2021-01-07 08:37:21 +00:00
//{"lastMonth", "datetime", 0, false, false, ""},
2020-07-14 21:50:29 +00:00
ccol ( "css_class" , 100 , "''" ) ,
2021-01-07 08:37:21 +00:00
{ "poll" , "int" , 0 , false , false , "0" } ,
2020-07-14 21:50:29 +00:00
ccol ( "data" , 200 , "''" ) ,
2018-12-27 05:42:41 +00:00
} ,
2020-07-14 21:50:29 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "tid" , "primary" , "" , false } ,
{ "title" , "fulltext" , "" , false } ,
{ "content" , "fulltext" , "" , false } ,
2018-12-27 05:42:41 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "replies" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "rid" , "int" , 0 , false , true , "" } , // TODO: Rename to replyID?
{ "tid" , "int" , 0 , false , false , "" } , // TODO: Rename to topicID?
2020-07-14 21:50:29 +00:00
text ( "content" ) ,
text ( "parsed_content" ) ,
createdAt ( ) ,
2021-01-07 08:37:21 +00:00
{ "createdBy" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
{ "lastEdit" , "int" , 0 , false , false , "0" } ,
{ "lastEditBy" , "int" , 0 , false , false , "0" } ,
{ "lastUpdated" , "datetime" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "ip" , 200 , "''" ) ,
2021-01-07 08:37:21 +00:00
{ "likeCount" , "int" , 0 , false , false , "0" } ,
{ "attachCount" , "int" , 0 , false , false , "0" } ,
{ "words" , "int" , 0 , false , false , "1" } , // ? - replies has a default of 1 and topics has 0? why?
2020-07-14 21:50:29 +00:00
ccol ( "actionType" , 20 , "''" ) ,
2021-01-07 08:37:21 +00:00
{ "poll" , "int" , 0 , false , false , "0" } ,
2018-12-27 05:42:41 +00:00
} ,
2020-07-14 21:50:29 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "rid" , "primary" , "" , false } ,
{ "content" , "fulltext" , "" , false } ,
2018-12-27 05:42:41 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "attachments" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "attachID" , "int" , 0 , false , true , "" } ,
{ "sectionID" , "int" , 0 , false , false , "0" } ,
2020-07-14 21:50:29 +00:00
ccol ( "sectionTable" , 200 , "forums" ) ,
2021-01-07 08:37:21 +00:00
{ "originID" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "originTable" , 200 , "replies" ) ,
2021-01-07 08:37:21 +00:00
{ "uploadedBy" , "int" , 0 , false , false , "" } , // TODO; Make this a foreign key
2020-07-14 21:50:29 +00:00
ccol ( "path" , 200 , "" ) ,
ccol ( "extra" , 200 , "" ) ,
2018-12-27 05:42:41 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "attachID" , "primary" , "" , false } ,
2018-12-27 05:42:41 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "revisions" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "reviseID" , "int" , 0 , false , true , "" } ,
2020-07-14 21:50:29 +00:00
text ( "content" ) ,
2021-01-07 08:37:21 +00:00
{ "contentID" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "contentType" , 100 , "replies" ) ,
createdAt ( ) ,
2018-03-31 05:25:27 +00:00
// TODO: Add a createdBy column?
2017-10-16 07:32:58 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "reviseID" , "primary" , "" , false } ,
2018-02-10 15:07:21 +00:00
} ,
2017-10-16 07:32:58 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "polls" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "pollID" , "int" , 0 , false , true , "" } ,
{ "parentID" , "int" , 0 , false , false , "0" } ,
2020-07-14 21:50:29 +00:00
ccol ( "parentTable" , 100 , "topics" ) , // topics, replies
2021-01-07 08:37:21 +00:00
{ "type" , "int" , 0 , false , false , "0" } ,
{ "options" , "json" , 0 , false , false , "" } ,
{ "votes" , "int" , 0 , false , false , "0" } ,
2018-01-25 04:57:33 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "pollID" , "primary" , "" , false } ,
2018-01-25 04:57:33 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "polls_options" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "pollID" , "int" , 0 , false , false , "" } ,
{ "option" , "int" , 0 , false , false , "0" } ,
{ "votes" , "int" , 0 , false , false , "0" } ,
2019-01-21 12:27:59 +00:00
} , nil ,
2018-01-28 14:30:24 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "polls_votes" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "pollID" , "int" , 0 , false , false , "" } ,
{ "uid" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
{ "option" , "int" , 0 , false , false , "0" } ,
2020-07-14 21:50:29 +00:00
createdAt ( "castAt" ) ,
ccol ( "ip" , 200 , "''" ) ,
2019-01-21 12:27:59 +00:00
} , nil ,
2018-01-25 04:57:33 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "users_replies" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "rid" , "int" , 0 , false , true , "" } ,
{ "uid" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
2020-07-14 21:50:29 +00:00
text ( "content" ) ,
text ( "parsed_content" ) ,
createdAt ( ) ,
2021-01-07 08:37:21 +00:00
{ "createdBy" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
{ "lastEdit" , "int" , 0 , false , false , "0" } ,
{ "lastEditBy" , "int" , 0 , false , false , "0" } ,
2020-07-14 21:50:29 +00:00
ccol ( "ip" , 200 , "''" ) ,
2017-11-12 05:25:04 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "rid" , "primary" , "" , false } ,
2017-10-16 07:32:58 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "likes" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "weight" , "tinyint" , 0 , false , false , "1" } ,
{ "targetItem" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "targetType" , 50 , "replies" ) ,
2021-01-07 08:37:21 +00:00
{ "sentBy" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
2020-07-14 21:50:29 +00:00
createdAt ( ) ,
2021-01-07 08:37:21 +00:00
{ "recalc" , "tinyint" , 0 , false , false , "0" } ,
2019-01-21 12:27:59 +00:00
} , nil ,
2017-10-16 07:32:58 +00:00
)
2021-04-03 09:28:00 +00:00
//columns("participants,createdBy,createdAt,lastReplyBy,lastReplyAt").Where("cid=?")
2019-10-06 22:20:37 +00:00
createTable ( "conversations" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "cid" , "int" , 0 , false , true , "" } ,
{ "createdBy" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
2020-07-14 21:50:29 +00:00
createdAt ( ) ,
2021-01-07 08:37:21 +00:00
{ "lastReplyAt" , "datetime" , 0 , false , false , "" } ,
{ "lastReplyBy" , "int" , 0 , false , false , "" } ,
2019-07-26 23:18:32 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "cid" , "primary" , "" , false } ,
2019-07-26 23:18:32 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "conversations_posts" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "pid" , "int" , 0 , false , true , "" } ,
{ "cid" , "int" , 0 , false , false , "" } ,
{ "createdBy" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "body" , 50 , "" ) ,
ccol ( "post" , 50 , "''" ) ,
2019-07-26 23:18:32 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "pid" , "primary" , "" , false } ,
2019-07-26 23:18:32 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "conversations_participants" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "uid" , "int" , 0 , false , false , "" } ,
{ "cid" , "int" , 0 , false , false , "" } ,
2019-07-26 23:18:32 +00:00
} , nil ,
2019-08-14 10:39:04 +00:00
)
2019-07-26 23:18:32 +00:00
2019-10-07 21:22:33 +00:00
/ *
2019-10-11 00:57:33 +00:00
createTable ( "users_friends" , "" , "" ,
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "uid" , "int" , 0 , false , false , "" } ,
{ "uid2" , "int" , 0 , false , false , "" } ,
2019-10-11 00:57:33 +00:00
} , nil ,
)
createTable ( "users_friends_invites" , "" , "" ,
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "requester" , "int" , 0 , false , false , "" } ,
{ "target" , "int" , 0 , false , false , "" } ,
2019-10-11 00:57:33 +00:00
} , nil ,
)
2019-10-07 21:22:33 +00:00
* /
2019-10-18 00:35:13 +00:00
createTable ( "users_blocks" , "" , "" ,
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "blocker" , "int" , 0 , false , false , "" } ,
{ "blockedUser" , "int" , 0 , false , false , "" } ,
2019-10-18 00:35:13 +00:00
} , nil ,
)
2019-10-06 22:20:37 +00:00
createTable ( "activity_stream_matches" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "watcher" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
{ "asid" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
2019-10-07 21:22:33 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 08:37:21 +00:00
{ "asid,asid" , "foreign" , "activity_stream" , true } ,
2019-05-06 04:04:00 +00:00
} ,
2017-10-16 07:32:58 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "activity_stream" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 08:37:21 +00:00
{ "asid" , "int" , 0 , false , true , "" } ,
{ "actor" , "int" , 0 , false , false , "" } , /* the one doing the act */ // TODO: Make this a foreign key
{ "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 ( "elementType" , 50 , "" ) , /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */
2020-07-14 21:50:29 +00:00
// replacement for elementType
tC { "elementTable" , "int" , 0 , false , false , "0" } ,
2021-01-07 09:15:39 +00:00
{ "elementID" , "int" , 0 , false , false , "" } , /* the ID of the element being acted upon */
2020-07-14 21:50:29 +00:00
createdAt ( ) ,
ccol ( "extra" , 200 , "''" ) ,
2017-10-16 07:32:58 +00:00
} ,
2020-07-14 21:50:29 +00:00
[ ] tK {
2021-01-07 09:15:39 +00:00
{ "asid" , "primary" , "" , false } ,
2017-10-16 07:32:58 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "activity_subscriptions" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "user" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
{ "targetID" , "int" , 0 , false , false , "" } , /* the ID of the element being acted upon */
ccol ( "targetType" , 50 , "" ) , /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */
{ "level" , "int" , 0 , false , false , "0" } , /* 0: Mentions (aka the global default for any post), 1: Replies To You, 2: All Replies*/
2019-01-21 12:27:59 +00:00
} , nil ,
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 */
2019-10-06 22:20:37 +00:00
createTable ( "settings" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2020-07-14 21:50:29 +00:00
ccol ( "name" , 180 , "" ) ,
ccol ( "content" , 250 , "" ) ,
ccol ( "type" , 50 , "" ) ,
ccol ( "constraints" , 200 , "''" ) ,
2017-10-16 07:32:58 +00:00
} ,
2021-01-07 09:15:39 +00:00
[ ] tK {
{ "name" , "unique" , "" , false } ,
2017-10-16 07:32:58 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "word_filters" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "wfid" , "int" , 0 , false , true , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "find" , 200 , "" ) ,
ccol ( "replacement" , 200 , "" ) ,
2017-10-16 07:32:58 +00:00
} ,
2021-01-07 09:15:39 +00:00
[ ] tK {
{ "wfid" , "primary" , "" , false } ,
2017-10-16 07:32:58 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "plugins" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2020-07-14 21:50:29 +00:00
ccol ( "uname" , 180 , "" ) ,
bcol ( "active" , false ) ,
bcol ( "installed" , false ) ,
2017-10-16 07:32:58 +00:00
} ,
2021-01-07 09:15:39 +00:00
[ ] tK {
{ "uname" , "unique" , "" , false } ,
2017-10-16 07:32:58 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "themes" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2020-07-14 21:50:29 +00:00
ccol ( "uname" , 180 , "" ) ,
bcol ( "default" , false ) ,
//text("profileUserVars"),
2017-10-16 07:32:58 +00:00
} ,
2021-01-07 09:15:39 +00:00
[ ] tK {
{ "uname" , "unique" , "" , false } ,
2017-10-16 07:32:58 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "widgets" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "wid" , "int" , 0 , false , true , "" } ,
{ "position" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "side" , 100 , "" ) ,
ccol ( "type" , 100 , "" ) ,
bcol ( "active" , false ) ,
ccol ( "location" , 100 , "" ) ,
text ( "data" ) ,
2017-11-12 05:25:04 +00:00
} ,
2021-01-07 09:15:39 +00:00
[ ] tK {
{ "wid" , "primary" , "" , false } ,
2019-01-21 12:27:59 +00:00
} ,
2017-10-16 07:32:58 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "menus" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "mid" , "int" , 0 , false , true , "" } ,
2018-04-22 12:33:56 +00:00
} ,
2021-01-07 09:15:39 +00:00
[ ] tK {
{ "mid" , "primary" , "" , false } ,
2018-04-22 12:33:56 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "menu_items" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "miid" , "int" , 0 , false , true , "" } ,
{ "mid" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "name" , 200 , "''" ) ,
ccol ( "htmlID" , 200 , "''" ) ,
ccol ( "cssClass" , 200 , "''" ) ,
ccol ( "position" , 100 , "" ) ,
ccol ( "path" , 200 , "''" ) ,
ccol ( "aria" , 200 , "''" ) ,
ccol ( "tooltip" , 200 , "''" ) ,
ccol ( "tmplName" , 200 , "''" ) ,
2021-01-07 09:15:39 +00:00
{ "order" , "int" , 0 , false , false , "0" } ,
2019-07-26 23:18:32 +00:00
2020-07-14 21:50:29 +00:00
bcol ( "guestOnly" , false ) ,
bcol ( "memberOnly" , false ) ,
bcol ( "staffOnly" , false ) ,
bcol ( "adminOnly" , false ) ,
2018-12-27 05:42:41 +00:00
} ,
2020-07-14 21:50:29 +00:00
[ ] tK {
2021-01-07 09:15:39 +00:00
{ "miid" , "primary" , "" , false } ,
2018-12-27 05:42:41 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "pages" , mysqlPre , mysqlCol ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "pid" , "int" , 0 , false , true , "" } ,
2020-07-14 21:50:29 +00:00
//ccol("path", 200, ""),
ccol ( "name" , 200 , "" ) ,
ccol ( "title" , 200 , "" ) ,
text ( "body" ) ,
2018-05-27 09:36:35 +00:00
// TODO: Make this a table?
2020-07-14 21:50:29 +00:00
text ( "allowedGroups" ) ,
2021-01-07 09:15:39 +00:00
{ "menuID" , "int" , 0 , false , false , "-1" } , // simple sidebar menu
2018-05-27 09:36:35 +00:00
} ,
2020-07-14 21:50:29 +00:00
[ ] tK {
2021-01-07 09:15:39 +00:00
{ "pid" , "primary" , "" , false } ,
2018-05-27 09:36:35 +00:00
} ,
)
2019-10-06 22:20:37 +00:00
createTable ( "registration_logs" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "rlid" , "int" , 0 , false , true , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "username" , 100 , "" ) ,
2021-01-07 09:15:39 +00:00
{ "email" , "varchar" , 100 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "failureReason" , 100 , "" ) ,
bcol ( "success" , false ) , // Did this attempt succeed?
ccol ( "ipaddress" , 200 , "" ) ,
createdAt ( "doneAt" ) ,
2018-05-16 10:46:14 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 09:15:39 +00:00
{ "rlid" , "primary" , "" , false } ,
2018-05-16 10:46:14 +00:00
} ,
)
2018-04-03 04:34:07 +00:00
2019-10-06 22:20:37 +00:00
createTable ( "login_logs" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "lid" , "int" , 0 , false , true , "" } ,
{ "uid" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
bcol ( "success" , false ) , // Did this attempt succeed?
ccol ( "ipaddress" , 200 , "" ) ,
createdAt ( "doneAt" ) ,
2018-12-17 04:58:55 +00:00
} ,
2021-04-03 09:28:00 +00:00
[ ] tK {
2021-01-07 09:15:39 +00:00
{ "lid" , "primary" , "" , false } ,
2018-12-17 04:58:55 +00:00
} ,
)
2018-12-14 04:08:53 +00:00
2019-10-06 22:20:37 +00:00
createTable ( "moderation_logs" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2020-07-14 21:50:29 +00:00
ccol ( "action" , 100 , "" ) ,
2021-01-07 09:15:39 +00:00
{ "elementID" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "elementType" , 100 , "" ) ,
ccol ( "ipaddress" , 200 , "" ) ,
2021-01-07 09:15:39 +00:00
{ "actorID" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
{ "doneAt" , "datetime" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
text ( "extra" ) ,
2019-01-21 12:27:59 +00:00
} , nil ,
2017-10-16 07:32:58 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "administration_logs" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2020-07-14 21:50:29 +00:00
ccol ( "action" , 100 , "" ) ,
2021-01-07 09:15:39 +00:00
{ "elementID" , "int" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "elementType" , 100 , "" ) ,
ccol ( "ipaddress" , 200 , "" ) ,
2021-01-07 09:15:39 +00:00
{ "actorID" , "int" , 0 , false , false , "" } , // TODO: Make this a foreign key
{ "doneAt" , "datetime" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
text ( "extra" ) ,
2019-01-21 12:27:59 +00:00
} , nil ,
2017-10-16 07:32:58 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "viewchunks" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "count" , "int" , 0 , false , false , "0" } ,
{ "avg" , "int" , 0 , false , false , "0" } ,
{ "createdAt" , "datetime" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "route" , 200 , "" ) , // TODO: set a default empty here
2019-01-21 12:27:59 +00:00
} , nil ,
2017-12-10 03:43:30 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "viewchunks_agents" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "count" , "int" , 0 , false , false , "0" } ,
{ "createdAt" , "datetime" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "browser" , 200 , "" ) , // googlebot, firefox, opera, etc.
//ccol("version",0,""), // the version of the browser or bot
2019-01-21 12:27:59 +00:00
} , nil ,
2018-01-09 07:39:29 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "viewchunks_systems" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "count" , "int" , 0 , false , false , "0" } ,
{ "createdAt" , "datetime" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "system" , 200 , "" ) , // windows, android, unknown, etc.
2019-01-21 12:27:59 +00:00
} , nil ,
2018-02-05 10:29:13 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "viewchunks_langs" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "count" , "int" , 0 , false , false , "0" } ,
{ "createdAt" , "datetime" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "lang" , 200 , "" ) , // en, ru, etc.
2019-01-21 12:27:59 +00:00
} , nil ,
2018-03-08 03:59:47 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "viewchunks_referrers" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "count" , "int" , 0 , false , false , "0" } ,
{ "createdAt" , "datetime" , 0 , false , false , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "domain" , 200 , "" ) ,
2019-01-21 12:27:59 +00:00
} , nil ,
2018-02-04 08:15:20 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "viewchunks_forums" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "count" , "int" , 0 , false , false , "0" } ,
{ "createdAt" , "datetime" , 0 , false , false , "" } ,
{ "forum" , "int" , 0 , false , false , "" } ,
2019-01-21 12:27:59 +00:00
} , nil ,
2018-02-19 04:26:01 +00:00
)
2017-12-19 03:53:13 +00:00
2019-10-06 22:20:37 +00:00
createTable ( "topicchunks" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "count" , "int" , 0 , false , false , "0" } ,
{ "createdAt" , "datetime" , 0 , false , false , "" } ,
2018-01-18 12:31:25 +00:00
// TODO: Add a column for the parent forum?
2019-01-21 12:27:59 +00:00
} , nil ,
2018-01-18 12:31:25 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "postchunks" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "count" , "int" , 0 , false , false , "0" } ,
{ "createdAt" , "datetime" , 0 , false , false , "" } ,
2018-01-14 12:03:20 +00:00
// TODO: Add a column for the parent topic / profile?
2019-01-21 12:27:59 +00:00
} , nil ,
2018-01-14 12:03:20 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "memchunks" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "count" , "int" , 0 , false , false , "0" } ,
{ "stack" , "int" , 0 , false , false , "0" } ,
{ "heap" , "int" , 0 , false , false , "0" } ,
{ "createdAt" , "datetime" , 0 , false , false , "" } ,
2019-05-01 06:59:51 +00:00
} , nil ,
)
2020-02-23 09:08:47 +00:00
createTable ( "perfchunks" , "" , "" ,
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "low" , "int" , 0 , false , false , "0" } ,
{ "high" , "int" , 0 , false , false , "0" } ,
{ "avg" , "int" , 0 , false , false , "0" } ,
{ "createdAt" , "datetime" , 0 , false , false , "" } ,
2020-02-23 09:08:47 +00:00
} , nil ,
)
2019-10-06 22:20:37 +00:00
createTable ( "sync" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "last_update" , "datetime" , 0 , false , false , "" } ,
2019-01-21 12:27:59 +00:00
} , nil ,
2017-10-16 07:32:58 +00:00
)
2019-10-06 22:20:37 +00:00
createTable ( "updates" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "dbVersion" , "int" , 0 , false , false , "0" } ,
2019-01-21 12:27:59 +00:00
} , nil ,
2018-12-17 04:58:55 +00:00
)
2018-10-06 13:14:11 +00:00
2019-10-06 22:20:37 +00:00
createTable ( "meta" , "" , "" ,
2019-07-26 23:18:32 +00:00
[ ] tC {
2020-07-14 21:50:29 +00:00
ccol ( "name" , 200 , "" ) ,
ccol ( "value" , 200 , "" ) ,
2019-05-09 06:58:55 +00:00
} , nil ,
)
2020-07-14 21:50:29 +00:00
/ * createTable ( "tables" , "" , "" ,
2020-03-21 08:55:15 +00:00
[ ] tC {
2021-01-07 09:15:39 +00:00
{ "id" , "int" , 0 , false , true , "" } ,
2020-07-14 21:50:29 +00:00
ccol ( "name" , 200 , "" ) ,
2020-03-21 08:55:15 +00:00
} ,
2020-07-14 21:50:29 +00:00
[ ] tK {
2021-01-07 09:15:39 +00:00
{ "id" , "primary" , "" , false } ,
{ "name" , "unique" , "" , false } ,
2020-03-21 08:55:15 +00:00
} ,
) * /
2019-10-06 22:20:37 +00:00
return err
2017-10-16 07:32:58 +00:00
}