21 lines
961 B
SQL
21 lines
961 B
SQL
create table if not exists stored_files (
|
|
id bigserial primary key,
|
|
guid uuid not null default gen_random_uuid(),
|
|
thought_id uuid references thoughts(guid) on delete set null,
|
|
project_id uuid references projects(guid) on delete set null,
|
|
name text not null,
|
|
media_type text not null,
|
|
kind text not null default 'file',
|
|
encoding text not null default 'base64',
|
|
size_bytes bigint not null,
|
|
sha256 text not null,
|
|
content bytea not null,
|
|
created_at timestamptz not null default now(),
|
|
updated_at timestamptz not null default now(),
|
|
constraint stored_files_guid_unique unique (guid)
|
|
);
|
|
|
|
create index if not exists stored_files_thought_id_idx on stored_files (thought_id);
|
|
create index if not exists stored_files_project_id_idx on stored_files (project_id);
|
|
create index if not exists stored_files_sha256_idx on stored_files (sha256);
|