f11f4def43
Clean Set Up * fail * starteddb * constraint * cleantest * fixqueries * fixtests * storemimetype * buffer * tests * setup * passingtests * pdfHElloWorld * rm * test * notodos * tests * clean * testpdf
43 lines
1.3 KiB
SQL
43 lines
1.3 KiB
SQL
CREATE TABLE documents (
|
|
id uuid primary key DEFAULT uuid_generate_v7(),
|
|
jobId uuid not null,
|
|
hash text not null,
|
|
foreign key (jobId) references jobs(id),
|
|
unique(jobId, hash)
|
|
);
|
|
|
|
CREATE TABLE documentEntries (
|
|
id uuid primary key DEFAULT uuid_generate_v7(),
|
|
documentId uuid not null,
|
|
bucket text not null,
|
|
key text not null,
|
|
foreign key (documentId) references documents(id)
|
|
);
|
|
|
|
CREATE TYPE cleanFailType AS ENUM ('invalid_mimetype');
|
|
CREATE TYPE cleanMimeTypes AS ENUM ('application/pdf');
|
|
|
|
CREATE TABLE documentCleans (
|
|
id uuid primary key DEFAULT uuid_generate_v7(),
|
|
documentId uuid not null,
|
|
version int not null,
|
|
bucket text,
|
|
key text,
|
|
mimetype cleanMimeTypes,
|
|
fail cleanFailType,
|
|
foreign key (documentId) references documents(id),
|
|
CONSTRAINT bucket_and_key_together CHECK ((bucket IS NULL) = (key IS NULL) and (bucket is null) = (mimetype is null)),
|
|
CONSTRAINT location_xor_fail CHECK (
|
|
(bucket IS NOT NULL) != (fail IS NOT NULL)
|
|
)
|
|
);
|
|
|
|
CREATE TABLE documentTextExtractions (
|
|
id uuid primary key DEFAULT uuid_generate_v7(),
|
|
cleanEntryId uuid not null,
|
|
version int not null,
|
|
bucket text not null,
|
|
key text not null,
|
|
foreign key (cleanEntryId) references documentCleans(id)
|
|
);
|