mirror of https://gitlab.com/litecord/litecord.git
remove all migrations, rename schema.sql to a 0_base.sql
This commit is contained in:
parent
4509ede535
commit
02978542e7
|
|
@ -1,15 +0,0 @@
|
||||||
CREATE TABLE IF NOT EXISTS attachments (
|
|
||||||
id bigint PRIMARY KEY,
|
|
||||||
|
|
||||||
channel_id bigint REFERENCES channels (id),
|
|
||||||
message_id bigint REFERENCES messages (id),
|
|
||||||
|
|
||||||
filename text NOT NULL,
|
|
||||||
filesize integer,
|
|
||||||
|
|
||||||
image boolean DEFAULT FALSE,
|
|
||||||
|
|
||||||
-- only not null if image=true
|
|
||||||
height integer DEFAULT NULL,
|
|
||||||
width integer DEFAULT NULL
|
|
||||||
);
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
-- 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);
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
DROP TABLE guild_features;
|
|
||||||
DROP TABLE features;
|
|
||||||
|
|
||||||
-- this should do the trick
|
|
||||||
ALTER TABLE guilds ADD COLUMN features text[] NOT NULL DEFAULT '{}';
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
-- vanity url table, the mapping is 1-1 for guilds and vanity urls
|
|
||||||
CREATE TABLE IF NOT EXISTS vanity_invites (
|
|
||||||
guild_id bigint REFERENCES guilds (id) PRIMARY KEY,
|
|
||||||
code text REFERENCES invites (code) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
ALTER TABLE guilds ADD COLUMN description text DEFAULT NULL;
|
|
||||||
ALTER TABLE guilds ADD COLUMN banner text DEFAULT NULL;
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
ALTER TABLE webhooks ALTER COLUMN avatar DROP NOT NULL;
|
|
||||||
ALTER TABLE webhooks ALTER COLUMN avatar SET DEFAULT NULL;
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
-- this is a tricky one. blame discord
|
|
||||||
|
|
||||||
-- first, remove all messages made by webhooks (safety check)
|
|
||||||
DELETE FROM messages WHERE author_id is null;
|
|
||||||
|
|
||||||
-- delete the column, removing the fkey. no connection anymore.
|
|
||||||
ALTER TABLE messages DROP COLUMN webhook_id;
|
|
||||||
|
|
||||||
-- add a message_webhook_info table. more on that in Storage._inject_author
|
|
||||||
CREATE TABLE IF NOT EXISTS message_webhook_info (
|
|
||||||
message_id bigint REFERENCES messages (id) PRIMARY KEY,
|
|
||||||
|
|
||||||
webhook_id bigint,
|
|
||||||
name text DEFAULT '<invalid>',
|
|
||||||
avatar text DEFAULT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
-- unused tables
|
|
||||||
DROP TABLE message_embeds;
|
|
||||||
DROP TABLE embeds;
|
|
||||||
|
|
||||||
ALTER TABLE messages
|
|
||||||
ADD COLUMN embeds jsonb DEFAULT '[]'
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
|
|
||||||
-- new icons table
|
|
||||||
CREATE TABLE IF NOT EXISTS icons (
|
|
||||||
scope text NOT NULL,
|
|
||||||
key text,
|
|
||||||
hash text UNIQUE NOT NULL,
|
|
||||||
mime text NOT NULL,
|
|
||||||
PRIMARY KEY (scope, hash, mime)
|
|
||||||
);
|
|
||||||
|
|
||||||
-- dummy attachments table for now.
|
|
||||||
CREATE TABLE IF NOT EXISTS attachments (
|
|
||||||
id bigint NOT NULL,
|
|
||||||
PRIMARY KEY (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
-- remove the old columns referencing the files table
|
|
||||||
ALTER TABLE users DROP COLUMN avatar;
|
|
||||||
ALTER TABLE users ADD COLUMN avatar text REFERENCES icons (hash) DEFAULT NULL;
|
|
||||||
|
|
||||||
ALTER TABLE group_dm_channels DROP COLUMN icon;
|
|
||||||
ALTER TABLE group_dm_channels ADD COLUMN icon text REFERENCES icons (hash);
|
|
||||||
|
|
||||||
ALTER TABLE guild_emoji DROP COLUMN image;
|
|
||||||
ALTER TABLE guild_emoji ADD COLUMN image text REFERENCES icons (hash);
|
|
||||||
|
|
||||||
ALTER TABLE guilds DROP COLUMN icon;
|
|
||||||
ALTER TABLE guilds ADD COLUMN icon text REFERENCES icons (hash) DEFAULT NULL;
|
|
||||||
|
|
||||||
-- this one is a change from files to the attachments table
|
|
||||||
ALTER TABLE message_attachments DROP COLUMN attachment;
|
|
||||||
ALTER TABLE guild_emoji ADD COLUMN attachment bigint REFERENCES attachments (id);
|
|
||||||
|
|
||||||
-- remove files table
|
|
||||||
DROP TABLE files;
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
-- drop main primary key
|
|
||||||
-- since hash can now be nullable
|
|
||||||
ALTER TABLE icons DROP CONSTRAINT "icons_pkey";
|
|
||||||
|
|
||||||
-- remove not null from hash column
|
|
||||||
ALTER TABLE icons ALTER COLUMN hash DROP NOT NULL;
|
|
||||||
|
|
||||||
-- add new primary key, without hash
|
|
||||||
ALTER TABLE icons ADD CONSTRAINT icons_pkey PRIMARY KEY (scope, key);
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
CREATE TABLE IF NOT EXISTS instance_invites (
|
|
||||||
code text PRIMARY KEY,
|
|
||||||
|
|
||||||
created_at timestamp without time zone default (now() at time zone 'utc'),
|
|
||||||
|
|
||||||
uses bigint DEFAULT 0,
|
|
||||||
max_uses bigint DEFAULT -1
|
|
||||||
);
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
ALTER TABLE messages ADD COLUMN guild_id bigint REFERENCES guilds (id) ON DELETE CASCADE;
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
-- require_colons seems to be true for all custom emoji.
|
|
||||||
ALTER TABLE guild_emoji ALTER COLUMN require_colons SET DEFAULT true;
|
|
||||||
|
|
||||||
-- retroactively update all other emojis
|
|
||||||
UPDATE guild_emoji SET require_colons=true;
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
ALTER TABLE guild_text_channels
|
|
||||||
ADD COLUMN rate_limit_per_user bigint DEFAULT 0;
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
-- update roles.color default to 0
|
|
||||||
ALTER TABLE roles
|
|
||||||
ALTER COLUMN color SET DEFAULT 0;
|
|
||||||
|
|
||||||
-- update all existing guild default roles to
|
|
||||||
-- color=0
|
|
||||||
UPDATE roles
|
|
||||||
SET color = 0
|
|
||||||
WHERE roles.id = roles.guild_id;
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
ALTER TABLE users ALTER COLUMN email DROP NOT NULL;
|
|
||||||
ALTER TABLE users ALTER COLUMN email SET DEFAULT NULL;
|
|
||||||
Loading…
Reference in New Issue