Actually save things! Yay!
This commit is contained in:
1
migrations/20230319163531_timestamp_function.down.sql
Normal file
1
migrations/20230319163531_timestamp_function.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP FUNCTION IF EXISTS set_updated_timestamp;
|
||||
7
migrations/20230319163531_timestamp_function.up.sql
Normal file
7
migrations/20230319163531_timestamp_function.up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE OR REPLACE FUNCTION set_updated_timestamp()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.updated_at = now();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ language 'plpgsql';
|
||||
1
migrations/20230319165242_facts.down.sql
Normal file
1
migrations/20230319165242_facts.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS "facts";
|
||||
15
migrations/20230319165242_facts.up.sql
Normal file
15
migrations/20230319165242_facts.up.sql
Normal 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();
|
||||
Reference in New Issue
Block a user