Files
picrinth-server/tables.sql
2025-07-29 20:22:14 +03:00

29 lines
883 B
SQL

CREATE TABLE picrinth.users (
id serial not null,
username text not null,
"password" text not null,
"role" text not null default "user",
"disabled" bool not null,
groups_ids integer[] NULL,
last_seen_at timestamp with time zone null,
created_at timestamp with time zone null,
CONSTRAINT username_unique UNIQUE (username)
);
CREATE TABLE picrinth.groups (
id serial not null,
groupname text not null,
invite_code text not null,
created_at timestamp with time zone null,
CONSTRAINT groupname_unique UNIQUE (groupname)
);
create table picrinth.group_members (
username text,
groupname text,
joined_at timestamp with time zone null,
PRIMARY KEY (username, groupname)
FOREIGN KEY (username) REFERENCES users (username) on delete cascade on update cascade
FOREIGN KEY (groupname) REFERENCES groups (groupname) on delete cascade on update cascade
);