# HG changeset patch # User jbe # Date 1581010846 -3600 # Node ID f02b7ea489715154aaa4b50118fc6c457c3c8a75 # Parent d34f8403d2c6fc3ba6dfdec5edd23d00fd69d744 Added tables "file" and "draft_attachment" diff -r d34f8403d2c6 -r f02b7ea48971 core.sql --- a/core.sql Mon Aug 26 15:52:03 2019 +0200 +++ b/core.sql Thu Feb 06 18:40:46 2020 +0100 @@ -53,6 +53,21 @@ COMMENT ON COLUMN "contingent"."initiative_limit" IS 'Number of new initiatives to be opened by each member within a given time frame'; +CREATE TABLE "file" ( + "id" SERIAL8 PRIMARY KEY, + "hash" TEXT NOT NULL UNIQUE, + "data" BYTEA NOT NULL, + "preview_data" BYTEA, + "preview_content_type" TEXT ); + +COMMENT ON TABLE "file" IS 'Table holding file contents for draft attachments'; + +COMMENT ON COLUMN "file"."hash" IS 'Hash of file contents to avoid storing duplicates'; +COMMENT ON COLUMN "file"."data" IS 'Binary content'; +COMMENT ON COLUMN "file"."preview_data" IS 'Preview (e.g. preview image)'; +COMMENT ON COLUMN "file"."preview_content_type" IS 'Content type of "preview_data"'; + + CREATE TABLE "member" ( "id" SERIAL4 PRIMARY KEY, "created" TIMESTAMPTZ NOT NULL DEFAULT now(), @@ -996,6 +1011,17 @@ COMMENT ON TABLE "rendered_draft" IS 'This table may be used by frontends to cache "rendered" drafts (e.g. HTML output generated from wiki text)'; +CREATE TABLE "draft_attachment" ( + "id" SERIAL8 PRIMARY KEY, + "draft_id" INT8 REFERENCES "draft" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + "file_id" INT8 REFERENCES "file" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, + "content_type" TEXT, + "title" TEXT, + "description" TEXT ); + +COMMENT ON TABLE "draft_attachment" IS 'Binary attachments for a draft (images, PDF file, etc.); Implicitly ordered through ''id'' column'; + + CREATE TABLE "suggestion" ( UNIQUE ("initiative_id", "id"), -- index needed for foreign-key on table "opinion" "initiative_id" INT4 NOT NULL REFERENCES "initiative" ("id") ON DELETE CASCADE ON UPDATE CASCADE,