-
Notifications
You must be signed in to change notification settings - Fork 8
/
schema.sql
96 lines (83 loc) · 3.24 KB
/
schema.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
create type application_command_type as enum ('chat_input', 'user', 'message');
create type anime_platform as enum ('anilist', 'myanimelist', 'kitsu');
create table guilds
(
id bigint not null
constraint guilds_pk
primary key,
added_at timestamp default CURRENT_TIMESTAMP not null
);
create table users
(
id bigint not null
constraint users_pk
primary key,
added_at timestamp default CURRENT_TIMESTAMP not null
);
create table guild_episode_notifications
(
guild_id bigint not null
constraint guild_episode_notifications_guilds_id_fk
references guilds
on delete cascade,
anilist_id integer not null,
title text not null,
added_by bigint not null
constraint guild_episode_notifications_users_id_fk
references users
on delete cascade,
added_at timestamp default CURRENT_TIMESTAMP not null
);
create unique index guild_episode_notifications_guild_id_anilist_id_uindex
on guild_episode_notifications (guild_id, anilist_id);
create table guild_channels
(
guild_id bigint not null
constraint guild_channels_guilds_id_fk
references guilds
on delete cascade,
channel_id bigint not null,
added_at timestamp default CURRENT_TIMESTAMP not null
);
create unique index guild_channels_guild_id_uindex
on guild_channels (guild_id);
create table guild_roles
(
guild_id bigint not null
constraint guild_roles_guilds_id_fk
references guilds
on delete cascade,
role_id bigint not null,
added_at timestamp default CURRENT_TIMESTAMP not null
);
create unique index guild_roles_guild_id_uindex
on guild_roles (guild_id);
create table user_profiles
(
user_id bigint not null
constraint user_profiles_users_id_fk
references users
on delete cascade,
platform anime_platform not null,
profile_id integer not null,
added_at timestamp default CURRENT_TIMESTAMP not null
);
create unique index user_profiles_user_id_platform_uindex
on user_profiles (user_id, platform);
create table guild_command_usages
(
shard_id integer not null,
guild_id bigint not null,
channel_id bigint not null,
user_id bigint not null,
command_name text not null,
command_type application_command_type not null,
used_at timestamp default CURRENT_TIMESTAMP not null
);
create table private_command_usages
(
user_id bigint not null,
command_name text not null,
command_type application_command_type not null,
used_at timestamp default CURRENT_TIMESTAMP not null
);