Catalogger.NET/Catalogger.Backend/Database/Migrations/001_init.up.sql

60 lines
1.6 KiB
SQL

create table if not exists guilds
(
id bigint not null primary key,
channels jsonb not null,
banned_systems text[] not null,
key_roles bigint[] not null
);
create table if not exists ignored_messages
(
id bigint not null primary key
);
create table if not exists invites
(
code text not null primary key,
guild_id bigint not null,
name text not null
);
create index if not exists ix_invites_guild_id on invites (guild_id);
create table if not exists messages
(
id bigint not null primary key,
original_id bigint,
user_id bigint not null,
channel_id bigint not null,
guild_id bigint not null,
member text,
system text,
username bytea not null,
content bytea not null,
metadata bytea,
attachment_size integer not null
);
create table if not exists watchlists
(
guild_id bigint not null,
user_id bigint not null,
added_at timestamp with time zone default now() not null,
moderator_id bigint not null,
reason text not null,
primary key (guild_id, user_id)
);
create table if not exists api_tokens
(
id integer generated by default as identity primary key,
dashboard_token text not null,
user_id text not null,
access_token text not null,
refresh_token text,
expires_at timestamp with time zone not null
);
-- Finally, drop the EFCore migrations table.
drop table if exists "__EFMigrationsHistory";