From d87a91de7770ea9c3bc28040be1e8a5bc8693ff6 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 17 Jan 2023 12:31:52 +0800 Subject: [PATCH] Add received_emails db table --- .../db/migrations/0107.do.received_emails.sql | 24 +++++++++++++++++++ .../migrations/0107.undo.received_emails.sql | 9 +++++++ 2 files changed, 33 insertions(+) create mode 100755 packages/db/migrations/0107.do.received_emails.sql create mode 100755 packages/db/migrations/0107.undo.received_emails.sql diff --git a/packages/db/migrations/0107.do.received_emails.sql b/packages/db/migrations/0107.do.received_emails.sql new file mode 100755 index 000000000..8b7f283cc --- /dev/null +++ b/packages/db/migrations/0107.do.received_emails.sql @@ -0,0 +1,24 @@ +-- Type: DO +-- Name: received_emails +-- Description: Create a table for received emails + +BEGIN; + +CREATE TABLE omnivore.received_emails ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(), + user_id uuid NOT NULL REFERENCES omnivore.user ON DELETE CASCADE, + "from" text NOT NULL, + "to" text NOT NULL, + subject text, + "text" text NOT NULL, + html text, + created_at timestamptz NOT NULL DEFAULT current_timestamp, + updated_at timestamptz NOT NULL DEFAULT current_timestamp +); + +CREATE TRIGGER received_emails_modtime BEFORE UPDATE ON omnivore.received_emails + FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column(); + +GRANT SELECT, INSERT, UPDATE ON omnivore.received_emails TO omnivore_user; + +COMMIT; diff --git a/packages/db/migrations/0107.undo.received_emails.sql b/packages/db/migrations/0107.undo.received_emails.sql new file mode 100755 index 000000000..cd03d6975 --- /dev/null +++ b/packages/db/migrations/0107.undo.received_emails.sql @@ -0,0 +1,9 @@ +-- Type: UNDO +-- Name: received_emails +-- Description: Create a table for received emails + +BEGIN; + +DROP TABLE IF EXISTS omnivore.received_emails; + +COMMIT;