17 lines
723 B
SQL
17 lines
723 B
SQL
CREATE TABLE IF NOT EXISTS files (
|
|
id serial,
|
|
file_id varchar(255) not null unique,
|
|
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;
|
|
ALTER TABLE files ALTER COLUMN delete_on_download set not null;
|
|
ALTER TABLE files ALTER COLUMN valid_till TYPE timestamptz;
|
|
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;
|