15 lines
650 B
MySQL
15 lines
650 B
MySQL
|
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();
|