From 37b7d9a4c7e6f853847b67f02d8ed74018e78389 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Mon, 21 Aug 2023 21:27:15 +0800 Subject: [PATCH] add sql for creating library_item_preview db table --- .../0121.do.library_item_preview.sql | 21 +++++++++++++++++++ .../0121.undo.library_item_preview.sql | 11 ++++++++++ 2 files changed, 32 insertions(+) create mode 100755 packages/db/migrations/0121.do.library_item_preview.sql create mode 100755 packages/db/migrations/0121.undo.library_item_preview.sql diff --git a/packages/db/migrations/0121.do.library_item_preview.sql b/packages/db/migrations/0121.do.library_item_preview.sql new file mode 100755 index 000000000..4b8a0189a --- /dev/null +++ b/packages/db/migrations/0121.do.library_item_preview.sql @@ -0,0 +1,21 @@ +-- Type: DO +-- Name: library_item_preview +-- Description: Create library_item_preview table + +BEGIN; + +CREATE TABLE omnivore.library_item_preview ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(), + sender_id uuid NOT NULL REFERENCES omnivore.user ON DELETE CASCADE, + recipient_ids uuid[] NOT NULL, -- Array of user ids + library_item_id uuid NOT NULL REFERENCES omnivore.library_item(id) ON DELETE CASCADE, + thumbnail text, + includes_note bool NOT NULL DEFAULT false, + includes_highlight bool NOT NULL DEFAULT false, + created_at timestamptz NOT NULL DEFAULT current_timestamp, + updated_at timestamptz NOT NULL DEFAULT current_timestamp +); + +CREATE TRIGGER update_library_item_preview_modtime BEFORE UPDATE ON omnivore.library_item_preview FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column(); + +COMMIT; diff --git a/packages/db/migrations/0121.undo.library_item_preview.sql b/packages/db/migrations/0121.undo.library_item_preview.sql new file mode 100755 index 000000000..c55d96584 --- /dev/null +++ b/packages/db/migrations/0121.undo.library_item_preview.sql @@ -0,0 +1,11 @@ +-- Type: UNDO +-- Name: library_item_preview +-- Description: Create library_item_preview table + +BEGIN; + +DROP TRIGGER update_library_item_preview_modtime; + +DROP TABLE omnivore.library_item_preview; + +COMMIT;