datatrash/init-db.sql

17 lines
723 B
MySQL
Raw Normal View History

2020-07-09 20:01:25 +00:00
CREATE TABLE IF NOT EXISTS files (
id serial,
2020-07-24 17:56:17 +00:00
file_id varchar(255) not null unique,
2020-07-09 20:01:25 +00:00
file_name varchar(255) not null,
valid_till timestamp not null,
kind varchar(255) not null,
primary key (id)
);
ALTER TABLE files ADD COLUMN IF NOT EXISTS delete_on_download boolean;
2021-09-24 20:51:13 +00:00
ALTER TABLE files ALTER COLUMN delete_on_download set not null;
2022-02-27 00:50:29 +00:00
ALTER TABLE files ALTER COLUMN valid_till TYPE timestamptz;
2022-09-30 13:06:24 +00:00
ALTER TABLE files ADD COLUMN IF NOT EXISTS content_type varchar(255) not null
GENERATED ALWAYS AS (CASE WHEN kind = 'text' THEN 'text/plain' ELSE 'application/octet-stream' END) STORED;
ALTER TABLE files ALTER COLUMN content_type DROP EXPRESSION IF EXISTS;
ALTER TABLE files DROP COLUMN IF EXISTS kind;