This commit is contained in:
Andreas Knuth 2025-09-19 11:29:59 -05:00
parent 637f9ef025
commit 65c595a018
3 changed files with 203 additions and 0 deletions

View File

@ -0,0 +1,24 @@
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;

View File

@ -0,0 +1,166 @@
{
"id": "2aede8c2-3ccd-4a5b-9af8-603ddc03843a",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.domains": {
"name": "domains",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"bucket": {
"name": "bucket",
"type": "text",
"primaryKey": false,
"notNull": true
},
"domain": {
"name": "domain",
"type": "text",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"domains_bucket_unique": {
"name": "domains_bucket_unique",
"nullsNotDistinct": false,
"columns": [
"bucket"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
},
"public.emails": {
"name": "emails",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"domain_id": {
"name": "domain_id",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"s3_key": {
"name": "s3_key",
"type": "text",
"primaryKey": false,
"notNull": true
},
"from": {
"name": "from",
"type": "text",
"primaryKey": false,
"notNull": false
},
"to": {
"name": "to",
"type": "text[]",
"primaryKey": false,
"notNull": false
},
"cc": {
"name": "cc",
"type": "text[]",
"primaryKey": false,
"notNull": false
},
"bcc": {
"name": "bcc",
"type": "text[]",
"primaryKey": false,
"notNull": false
},
"subject": {
"name": "subject",
"type": "text",
"primaryKey": false,
"notNull": false
},
"html": {
"name": "html",
"type": "text",
"primaryKey": false,
"notNull": false
},
"raw": {
"name": "raw",
"type": "text",
"primaryKey": false,
"notNull": false
},
"processed": {
"name": "processed",
"type": "boolean",
"primaryKey": false,
"notNull": false,
"default": false
},
"date": {
"name": "date",
"type": "timestamp",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"emails_domain_id_domains_id_fk": {
"name": "emails_domain_id_domains_id_fk",
"tableFrom": "emails",
"tableTo": "domains",
"columnsFrom": [
"domain_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"emails_s3_key_unique": {
"name": "emails_s3_key_unique",
"nullsNotDistinct": false,
"columns": [
"s3_key"
]
}
},
"policies": {},
"checkConstraints": {},
"isRLSEnabled": false
}
},
"enums": {},
"schemas": {},
"sequences": {},
"roles": {},
"policies": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}

View File

@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1758060605443,
"tag": "0000_wonderful_reptil",
"breakpoints": true
}
]
}