+ Badges introduction to database schemas

+ Adding some default empty list values where applicable
neighbors now has a default value of '[]' to enforce the "empty list" constraint on that field
This commit is contained in:
shockrah 2021-05-17 15:50:53 -07:00
parent e5e0875037
commit 36dbc8dd1e
5 changed files with 12 additions and 1 deletions

View File

@ -4,5 +4,6 @@ CREATE TABLE IF NOT EXISTS `channels` (
`name` VARCHAR(255) NOT NULL,
`description` VARCHAR(2048),
`kind` INTEGER NOT NULL,
`badges` VARCHAR(2048) DEFAULT '[]',
PRIMARY KEY(`id`), UNIQUE KEY(`name`)
);

View File

@ -1,10 +1,13 @@
-- TODO: add rate limiter in some form
-- PERMISSIONS start at 0 and full perms => all F's
-- badges are stored as ad-hoc json for better operability in db-lib
-- mysql_async's json feature is basically 100% undocc'ed and i don't want to deal with it tbh
CREATE TABLE IF NOT EXISTS `members`(
`id` BIGINT UNSIGNED NOT NULL,
`secret` varchar(256) NOT NULL,
`name` varchar(256) NOT NULL,
`status` integer NOT NULL,
`permissions` bigint UNSIGNED NOT NULL,
`badges` VARCHAR(2048) DEFAULT '[]',
PRIMARY KEY( `id` , `secret` )
);

View File

@ -6,5 +6,5 @@ CREATE TABLE IF NOT EXISTS `neighbors`(
`wsurl` VARCHAR(512),
`name` VARCHAR(512) NOT NULL,
`description` VARCHAR(1024),
`tags` VARCHAR(1024)
`tags` VARCHAR(1024) DEFAULT '[]'
);

View File

@ -0,0 +1 @@
DROP TABLE IF EXISTS `badges`;

View File

@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS `badges`(
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(256) NOT NULL,
`color` INTEGER UNSIGNED NOT NULL DEFAULT 0xFFFFFFFF,
PRIMARY KEY(`id`)
);