CREATE TABLE "domains" (
	"id" serial PRIMARY KEY NOT NULL,
	"bucket" text NOT NULL,
	"domain" text NOT NULL,
	CONSTRAINT "domains_bucket_unique" UNIQUE("bucket")
);
--> statement-breakpoint
CREATE TABLE "emails" (
	"id" serial PRIMARY KEY NOT NULL,
	"domain_id" integer NOT NULL,
	"s3_key" text NOT NULL,
	"from" text,
	"to" text[],
	"cc" text[],
	"bcc" text[],
	"subject" text,
	"html" text,
	"raw" text,
	"processed" boolean DEFAULT false,
	"date" timestamp,
	CONSTRAINT "emails_s3_key_unique" UNIQUE("s3_key")
);
--> statement-breakpoint
ALTER TABLE "emails" ADD CONSTRAINT "emails_domain_id_domains_id_fk" FOREIGN KEY ("domain_id") REFERENCES "public"."domains"("id") ON DELETE no action ON UPDATE no action;