Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Create memory_emails table
-- Stores the relationship between emails and memories

CREATE TABLE public.memory_emails (
id uuid NOT NULL DEFAULT gen_random_uuid(),
email_id uuid NOT NULL,
memory uuid NOT NULL,
message_id text NOT NULL,
created_at timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT memory_emails_pkey PRIMARY KEY (id),
CONSTRAINT memory_emails_email_id_unique UNIQUE (email_id),
CONSTRAINT memory_emails_message_id_unique UNIQUE (message_id),
CONSTRAINT memory_emails_memory_fkey FOREIGN KEY (memory)
REFERENCES memories(id) ON UPDATE CASCADE ON DELETE CASCADE
) TABLESPACE pg_default;
Comment thread
sweetmantech marked this conversation as resolved.

-- Enable Row Level Security
ALTER TABLE public.memory_emails ENABLE ROW LEVEL SECURITY;
Comment thread
sweetmantech marked this conversation as resolved.

-- Create index on memory for faster lookups
CREATE INDEX IF NOT EXISTS memory_emails_memory_idx
ON public.memory_emails(memory);

-- Create index on created_at for sorting
CREATE INDEX IF NOT EXISTS memory_emails_created_at_idx
ON public.memory_emails(created_at);