This repository has been archived on 2023-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
god-replacement-product-old/migrations/20230319165242_facts.up.sql

15 lines
650 B
MySQL
Raw Normal View History

2023-03-19 22:59:11 +01:00
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();