Add received_emails db table

This commit is contained in:
Hongbo Wu
2023-01-17 12:31:52 +08:00
parent 5ba8b6cc5e
commit d87a91de77
2 changed files with 33 additions and 0 deletions

View File

@ -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;

View File

@ -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;