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;