34 lines
783 B
MySQL
34 lines
783 B
MySQL
|
-- +migrate Up
|
||
|
|
||
|
create table users (
|
||
|
id integer primary key,
|
||
|
username text not null unique,
|
||
|
password text not null,
|
||
|
is_admin boolean not null default false
|
||
|
);
|
||
|
|
||
|
create table tokens (
|
||
|
id integer primary key,
|
||
|
user_id integer not null references users (id) on delete cascade,
|
||
|
token text not null unique
|
||
|
);
|
||
|
|
||
|
create table files (
|
||
|
id text primary key, -- uuid
|
||
|
user_id integer not null references users (id) on delete cascade,
|
||
|
filename text not null,
|
||
|
content_type text not null,
|
||
|
hash text not null,
|
||
|
size integer not null,
|
||
|
created_at integer not null,
|
||
|
expires integer,
|
||
|
|
||
|
unique(filename, hash)
|
||
|
);
|
||
|
|
||
|
-- +migrate Down
|
||
|
|
||
|
drop table files;
|
||
|
drop table tokens;
|
||
|
drop table users;
|