From 36dbc8dd1e39956602b894f73269d1e71aa00c31 Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 17 May 2021 15:50:53 -0700 Subject: [PATCH] + 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 --- json-api/migrations/2020-03-11-005217_channels/up.sql | 1 + json-api/migrations/2020-07-05-215114_members/up.sql | 3 +++ json-api/migrations/2021-05-04-200859_neighbors/up.sql | 2 +- json-api/migrations/2021-05-17-221928_badges/down.sql | 1 + json-api/migrations/2021-05-17-221928_badges/up.sql | 6 ++++++ 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 json-api/migrations/2021-05-17-221928_badges/down.sql create mode 100644 json-api/migrations/2021-05-17-221928_badges/up.sql diff --git a/json-api/migrations/2020-03-11-005217_channels/up.sql b/json-api/migrations/2020-03-11-005217_channels/up.sql index e37c630..e08fd88 100644 --- a/json-api/migrations/2020-03-11-005217_channels/up.sql +++ b/json-api/migrations/2020-03-11-005217_channels/up.sql @@ -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`) ); diff --git a/json-api/migrations/2020-07-05-215114_members/up.sql b/json-api/migrations/2020-07-05-215114_members/up.sql index 1309164..47b5b46 100644 --- a/json-api/migrations/2020-07-05-215114_members/up.sql +++ b/json-api/migrations/2020-07-05-215114_members/up.sql @@ -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` ) ); diff --git a/json-api/migrations/2021-05-04-200859_neighbors/up.sql b/json-api/migrations/2021-05-04-200859_neighbors/up.sql index c612dcd..45388df 100644 --- a/json-api/migrations/2021-05-04-200859_neighbors/up.sql +++ b/json-api/migrations/2021-05-04-200859_neighbors/up.sql @@ -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 '[]' ); diff --git a/json-api/migrations/2021-05-17-221928_badges/down.sql b/json-api/migrations/2021-05-17-221928_badges/down.sql new file mode 100644 index 0000000..78380e7 --- /dev/null +++ b/json-api/migrations/2021-05-17-221928_badges/down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS `badges`; \ No newline at end of file diff --git a/json-api/migrations/2021-05-17-221928_badges/up.sql b/json-api/migrations/2021-05-17-221928_badges/up.sql new file mode 100644 index 0000000..73d044b --- /dev/null +++ b/json-api/migrations/2021-05-17-221928_badges/up.sql @@ -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`) +); \ No newline at end of file