diff --git a/docs/lvsp.md b/docs/lvsp.md index 22af56c..de30b8a 100644 --- a/docs/lvsp.md +++ b/docs/lvsp.md @@ -126,7 +126,7 @@ time period. Sent by the server in reply to a HEARTBEAT message coming from the client. -The `health` field determines how well is the server's overall health. It is a +The `health` field is a measure of the servers's overall health. It is a float going from 0 to 1, where 0 is the worst health possible, and 1 is the best health possible. diff --git a/manage/cmd/migration/scripts/11_voice_regions_servers.sql b/manage/cmd/migration/scripts/11_voice_regions_servers.sql new file mode 100644 index 0000000..398c91a --- /dev/null +++ b/manage/cmd/migration/scripts/11_voice_regions_servers.sql @@ -0,0 +1,37 @@ +-- voice region data +-- NOTE: do NOT remove any rows. use deprectated=true and +-- DELETE FROM voice_servers instead. +CREATE TABLE IF NOT EXISTS voice_regions ( + -- always lowercase + id text PRIMARY KEY, + + -- "Russia", "Brazil", "Antartica", etc + name text NOT NULL, + + -- we don't have the concept of vip guilds yet, but better + -- future proof. + vip boolean DEFAULT FALSE, + + deprecated boolean DEFAULT FALSE, + + -- we don't have the concept of custom regions too. we don't have the + -- concept of official guilds either, but i'm keeping this in + custom boolean DEFAULT FALSE +); + +-- voice server pool. when someone wants to connect to voice, we choose +-- a server that is in the same region the guild is too, and choose the one +-- with the best health value +CREATE TABLE IF NOT EXISTS voice_servers ( + -- hostname is a reachable url, e.g "brazil2.example.com" + hostname text PRIMARY KEY, + region_id text REFERENCES voice_regions (id), + + -- health values are more thoroughly defined in the LVSP documentation + last_health float default 0.5 +); + + +ALTER TABLE guilds DROP COLUMN IF EXISTS region; +ALTER TABLE guilds ADD COLUMN + region text REFERENCES voice_regions (id); diff --git a/schema.sql b/schema.sql index 5eab831..269ff91 100644 --- a/schema.sql +++ b/schema.sql @@ -318,6 +318,40 @@ CREATE TABLE IF NOT EXISTS user_read_state ( PRIMARY KEY (user_id, channel_id) ); + +-- voice region data +-- NOTE: do NOT remove any rows. use deprectated=true and +-- DELETE FROM voice_servers instead. +CREATE TABLE IF NOT EXISTS voice_regions ( + -- always lowercase + id text PRIMARY KEY, + + -- "Russia", "Brazil", "Antartica", etc + name text NOT NULL, + + -- we don't have the concept of vip guilds yet, but better + -- future proof. + vip boolean DEFAULT FALSE, + + deprecated boolean DEFAULT FALSE, + + -- we don't have the concept of custom regions too. we don't have the + -- concept of official guilds either, but i'm keeping this in + custom boolean DEFAULT FALSE +); + +-- voice server pool. when someone wants to connect to voice, we choose +-- a server that is in the same region the guild is too, and choose the one +-- with the best health value +CREATE TABLE IF NOT EXISTS voice_servers ( + -- hostname is a reachable url, e.g "brazil2.example.com" + hostname text PRIMARY KEY, + region_id text REFERENCES voice_regions (id), + + -- health values are more thoroughly defined in the LVSP documentation + last_health float default 0.5 +); + CREATE TABLE IF NOT EXISTS guilds ( id bigint PRIMARY KEY NOT NULL, @@ -326,7 +360,7 @@ CREATE TABLE IF NOT EXISTS guilds ( splash text DEFAULT NULL, owner_id bigint NOT NULL REFERENCES users (id), - region text NOT NULL, + region text NOT NULL REFERENCES voice_regions (id), /* default no afk channel afk channel is voice-only.