Actually save things! Yay!

This commit is contained in:
2023-03-19 22:59:11 +01:00
parent 703c133149
commit 3f2f4fa733
9 changed files with 926 additions and 44 deletions

View File

@@ -0,0 +1,15 @@
CREATE TABLE IF NOT EXISTS "facts" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
"channel_id" text,
"author_id" text NOT NULL,
"last_interaction_id" text NOT NULL,
"name" text NOT NULL,
"value" text NOT NULL,
"expiration" interval NULL,
"version" int NOT NULL DEFAULT 0,
"created_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT facts_origin_key UNIQUE NULLS NOT DISTINCT ("channel_id", "author_id", "name")
);
CREATE TRIGGER "set_facts_updated" BEFORE
UPDATE ON "facts" FOR EACH ROW EXECUTE PROCEDURE set_updated_timestamp();