Add received_emails db table
This commit is contained in:
24
packages/db/migrations/0107.do.received_emails.sql
Executable file
24
packages/db/migrations/0107.do.received_emails.sql
Executable 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;
|
||||
9
packages/db/migrations/0107.undo.received_emails.sql
Executable file
9
packages/db/migrations/0107.undo.received_emails.sql
Executable 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;
|
||||
Reference in New Issue
Block a user