diff --git a/backend/drizzle/0000_sleepy_franklin_richards.sql b/backend/drizzle/0000_sleepy_franklin_richards.sql deleted file mode 100644 index 4f8730f..0000000 --- a/backend/drizzle/0000_sleepy_franklin_richards.sql +++ /dev/null @@ -1,194 +0,0 @@ --- Current sql file was generated after introspecting the database --- If you want to run this migration please uncomment this code before executing migrations -/* -CREATE TABLE "pgmigrations" ( - "id" serial PRIMARY KEY NOT NULL, - "name" varchar(255) NOT NULL, - "run_on" timestamp NOT NULL -); ---> statement-breakpoint -CREATE TABLE "admin_settings" ( - "key" text PRIMARY KEY NOT NULL, - "value" text NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "item_images" ( - "id" serial PRIMARY KEY NOT NULL, - "item_id" integer NOT NULL, - "image_path" text NOT NULL, - "sort_order" integer DEFAULT 0 NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "shipping_addresses" ( - "id" serial PRIMARY KEY NOT NULL, - "customer_id" integer NOT NULL, - "full_name" text NOT NULL, - "address_line1" text NOT NULL, - "address_line2" text, - "city" text NOT NULL, - "state" text NOT NULL, - "postal_code" text NOT NULL, - "country" text DEFAULT 'US' NOT NULL, - "is_default" boolean DEFAULT false NOT NULL, - "usps_validated" boolean DEFAULT false NOT NULL, - "usps_standardized" jsonb, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "items" ( - "id" serial PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "description" text, - "price_cents" integer NOT NULL, - "status" text DEFAULT 'pending' NOT NULL, - "reserved_until" timestamp with time zone, - "sold_at" timestamp with time zone, - "paypal_order_id" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "category_id" integer -); ---> statement-breakpoint -CREATE TABLE "tags" ( - "id" serial PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "color" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "categories" ( - "id" serial PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "parent_id" integer, - "sort_order" integer DEFAULT 0 NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "orders" ( - "id" serial PRIMARY KEY NOT NULL, - "item_id" integer, - "customer_id" integer, - "checkout_id" integer, - "processor" text NOT NULL, - "processor_order_id" text, - "amount_cents" integer, - "status" text, - "raw_event" jsonb, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "cart_items" ( - "id" serial PRIMARY KEY NOT NULL, - "cart_id" integer NOT NULL, - "item_id" integer NOT NULL, - "added_at" timestamp with time zone DEFAULT now() NOT NULL, - "expires_at" timestamp with time zone NOT NULL, - "last_reminder_sent_at" timestamp with time zone, - CONSTRAINT "cart_items_item_id_key" UNIQUE("item_id") -); ---> statement-breakpoint -CREATE TABLE "carts" ( - "id" serial PRIMARY KEY NOT NULL, - "customer_id" integer NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - CONSTRAINT "carts_customer_id_key" UNIQUE("customer_id") -); ---> statement-breakpoint -CREATE TABLE "customer_tokens" ( - "token" text PRIMARY KEY NOT NULL, - "customer_id" integer NOT NULL, - "kind" text NOT NULL, - "expires_at" timestamp with time zone NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "checkouts" ( - "id" serial PRIMARY KEY NOT NULL, - "customer_id" integer, - "shipping_address_id" integer, - "processor" text NOT NULL, - "processor_order_id" text, - "amount_cents" integer, - "status" text DEFAULT 'pending' NOT NULL, - "raw_event" jsonb, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "customer_sessions" ( - "token" text PRIMARY KEY NOT NULL, - "customer_id" integer NOT NULL, - "expires_at" timestamp with time zone NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "customers" ( - "id" serial PRIMARY KEY NOT NULL, - "email" text NOT NULL, - "password_hash" text NOT NULL, - "email_verified" boolean DEFAULT false NOT NULL, - "marketing_consent" boolean DEFAULT false NOT NULL, - "marketing_consent_at" timestamp with time zone, - "marketing_consent_text" text, - "unsubscribe_token" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "disabled_at" timestamp with time zone, - "favorite_alerts" boolean DEFAULT false NOT NULL, - "favorite_alerts_at" timestamp with time zone, - "favorite_alerts_text" text, - "first_name" text, - "last_name" text, - CONSTRAINT "customers_email_key" UNIQUE("email"), - CONSTRAINT "customers_unsubscribe_token_key" UNIQUE("unsubscribe_token") -); ---> statement-breakpoint -CREATE TABLE "item_tags" ( - "item_id" integer NOT NULL, - "tag_id" integer NOT NULL, - CONSTRAINT "item_tags_pkey" PRIMARY KEY("item_id","tag_id") -); ---> statement-breakpoint -CREATE TABLE "favorites" ( - "customer_id" integer NOT NULL, - "item_id" integer NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - CONSTRAINT "favorites_pkey" PRIMARY KEY("customer_id","item_id") -); ---> statement-breakpoint -CREATE TABLE "checkout_items" ( - "checkout_id" integer NOT NULL, - "item_id" integer NOT NULL, - "price_cents" integer NOT NULL, - CONSTRAINT "checkout_items_pkey" PRIMARY KEY("checkout_id","item_id") -); ---> statement-breakpoint -ALTER TABLE "item_images" ADD CONSTRAINT "item_images_item_id_fkey" FOREIGN KEY ("item_id") REFERENCES "public"."items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "shipping_addresses" ADD CONSTRAINT "shipping_addresses_customer_id_fkey" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "items" ADD CONSTRAINT "items_category_id_fkey" FOREIGN KEY ("category_id") REFERENCES "public"."categories"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "categories" ADD CONSTRAINT "categories_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "public"."categories"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "orders" ADD CONSTRAINT "orders_item_id_fkey" FOREIGN KEY ("item_id") REFERENCES "public"."items"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "orders" ADD CONSTRAINT "orders_customer_id_fkey" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "orders" ADD CONSTRAINT "orders_checkout_id_fkey" FOREIGN KEY ("checkout_id") REFERENCES "public"."checkouts"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_cart_id_fkey" FOREIGN KEY ("cart_id") REFERENCES "public"."carts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_item_id_fkey" FOREIGN KEY ("item_id") REFERENCES "public"."items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "carts" ADD CONSTRAINT "carts_customer_id_fkey" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "customer_tokens" ADD CONSTRAINT "customer_tokens_customer_id_fkey" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "checkouts" ADD CONSTRAINT "checkouts_customer_id_fkey" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "checkouts" ADD CONSTRAINT "checkouts_shipping_address_id_fkey" FOREIGN KEY ("shipping_address_id") REFERENCES "public"."shipping_addresses"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "customer_sessions" ADD CONSTRAINT "customer_sessions_customer_id_fkey" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "item_tags" ADD CONSTRAINT "item_tags_item_id_fkey" FOREIGN KEY ("item_id") REFERENCES "public"."items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "item_tags" ADD CONSTRAINT "item_tags_tag_id_fkey" FOREIGN KEY ("tag_id") REFERENCES "public"."tags"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "favorites" ADD CONSTRAINT "favorites_customer_id_fkey" FOREIGN KEY ("customer_id") REFERENCES "public"."customers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "favorites" ADD CONSTRAINT "favorites_item_id_fkey" FOREIGN KEY ("item_id") REFERENCES "public"."items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "checkout_items" ADD CONSTRAINT "checkout_items_checkout_id_fkey" FOREIGN KEY ("checkout_id") REFERENCES "public"."checkouts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "checkout_items" ADD CONSTRAINT "checkout_items_item_id_fkey" FOREIGN KEY ("item_id") REFERENCES "public"."items"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "items_category_id_idx" ON "items" USING btree ("category_id" int4_ops);--> statement-breakpoint -CREATE UNIQUE INDEX "tags_name_uniq" ON "tags" USING btree (lower(name) text_ops);--> statement-breakpoint -CREATE UNIQUE INDEX "categories_child_name_uniq" ON "categories" USING btree (parent_id text_ops,lower(name) int4_ops) WHERE (parent_id IS NOT NULL);--> statement-breakpoint -CREATE INDEX "categories_parent_id_idx" ON "categories" USING btree ("parent_id" int4_ops);--> statement-breakpoint -CREATE UNIQUE INDEX "categories_root_name_uniq" ON "categories" USING btree (lower(name) text_ops) WHERE (parent_id IS NULL);--> statement-breakpoint -CREATE INDEX "customers_disabled_at_idx" ON "customers" USING btree ("disabled_at" timestamptz_ops) WHERE (disabled_at IS NOT NULL);--> statement-breakpoint -CREATE INDEX "item_tags_tag_id_idx" ON "item_tags" USING btree ("tag_id" int4_ops);--> statement-breakpoint -CREATE INDEX "favorites_item_id_idx" ON "favorites" USING btree ("item_id" int4_ops); -*/ \ No newline at end of file diff --git a/backend/drizzle/0001_add_condition_note.sql b/backend/drizzle/0001_add_condition_note.sql deleted file mode 100644 index 20dccbb..0000000 --- a/backend/drizzle/0001_add_condition_note.sql +++ /dev/null @@ -1,7 +0,0 @@ -DROP INDEX "tags_name_uniq";--> statement-breakpoint -DROP INDEX "categories_child_name_uniq";--> statement-breakpoint -DROP INDEX "categories_root_name_uniq";--> statement-breakpoint -ALTER TABLE "items" ADD COLUMN "condition_note" text;--> statement-breakpoint -CREATE UNIQUE INDEX "tags_name_uniq" ON "tags" USING btree (lower(name));--> statement-breakpoint -CREATE UNIQUE INDEX "categories_child_name_uniq" ON "categories" USING btree (parent_id,lower(name)) WHERE (parent_id IS NOT NULL);--> statement-breakpoint -CREATE UNIQUE INDEX "categories_root_name_uniq" ON "categories" USING btree (lower(name)) WHERE (parent_id IS NULL); \ No newline at end of file diff --git a/backend/drizzle/meta/0000_snapshot.json b/backend/drizzle/meta/0000_snapshot.json deleted file mode 100644 index 60ef76c..0000000 --- a/backend/drizzle/meta/0000_snapshot.json +++ /dev/null @@ -1,1384 +0,0 @@ -{ - "id": "00000000-0000-0000-0000-000000000000", - "prevId": "", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.pgmigrations": { - "name": "pgmigrations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "run_on": { - "name": "run_on", - "type": "timestamp", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.admin_settings": { - "name": "admin_settings", - "schema": "", - "columns": { - "key": { - "name": "key", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.item_images": { - "name": "item_images", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "image_path": { - "name": "image_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "item_images_item_id_fkey": { - "name": "item_images_item_id_fkey", - "tableFrom": "item_images", - "tableTo": "items", - "schemaTo": "public", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.shipping_addresses": { - "name": "shipping_addresses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "address_line1": { - "name": "address_line1", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "address_line2": { - "name": "address_line2", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "city": { - "name": "city", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "postal_code": { - "name": "postal_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "country": { - "name": "country", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'US'" - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "usps_validated": { - "name": "usps_validated", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "usps_standardized": { - "name": "usps_standardized", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "shipping_addresses_customer_id_fkey": { - "name": "shipping_addresses_customer_id_fkey", - "tableFrom": "shipping_addresses", - "tableTo": "customers", - "schemaTo": "public", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.items": { - "name": "items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "price_cents": { - "name": "price_cents", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reserved_until": { - "name": "reserved_until", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "sold_at": { - "name": "sold_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "paypal_order_id": { - "name": "paypal_order_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "category_id": { - "name": "category_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "items_category_id_idx": { - "name": "items_category_id_idx", - "columns": [ - { - "expression": "category_id", - "asc": true, - "nulls": "last", - "opclass": "int4_ops", - "isExpression": false - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "items_category_id_fkey": { - "name": "items_category_id_fkey", - "tableFrom": "items", - "tableTo": "categories", - "schemaTo": "public", - "columnsFrom": [ - "category_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.tags": { - "name": "tags", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "color": { - "name": "color", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "tags_name_uniq": { - "name": "tags_name_uniq", - "columns": [ - { - "expression": "lower(name)", - "asc": true, - "nulls": "last", - "opclass": "text_ops", - "isExpression": true - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.categories": { - "name": "categories", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "parent_id": { - "name": "parent_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "categories_child_name_uniq": { - "name": "categories_child_name_uniq", - "columns": [ - { - "expression": "parent_id", - "asc": true, - "nulls": "last", - "opclass": "text_ops", - "isExpression": true - }, - { - "expression": "lower(name)", - "asc": true, - "nulls": "last", - "opclass": "int4_ops", - "isExpression": true - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "where": "(parent_id IS NOT NULL)", - "with": {} - }, - "categories_parent_id_idx": { - "name": "categories_parent_id_idx", - "columns": [ - { - "expression": "parent_id", - "asc": true, - "nulls": "last", - "opclass": "int4_ops", - "isExpression": false - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "categories_root_name_uniq": { - "name": "categories_root_name_uniq", - "columns": [ - { - "expression": "lower(name)", - "asc": true, - "nulls": "last", - "opclass": "text_ops", - "isExpression": true - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "where": "(parent_id IS NULL)", - "with": {} - } - }, - "foreignKeys": { - "categories_parent_id_fkey": { - "name": "categories_parent_id_fkey", - "tableFrom": "categories", - "tableTo": "categories", - "schemaTo": "public", - "columnsFrom": [ - "parent_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.orders": { - "name": "orders", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "checkout_id": { - "name": "checkout_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "processor": { - "name": "processor", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "processor_order_id": { - "name": "processor_order_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "amount_cents": { - "name": "amount_cents", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "raw_event": { - "name": "raw_event", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "orders_item_id_fkey": { - "name": "orders_item_id_fkey", - "tableFrom": "orders", - "tableTo": "items", - "schemaTo": "public", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "orders_customer_id_fkey": { - "name": "orders_customer_id_fkey", - "tableFrom": "orders", - "tableTo": "customers", - "schemaTo": "public", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "orders_checkout_id_fkey": { - "name": "orders_checkout_id_fkey", - "tableFrom": "orders", - "tableTo": "checkouts", - "schemaTo": "public", - "columnsFrom": [ - "checkout_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.cart_items": { - "name": "cart_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "cart_id": { - "name": "cart_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "added_at": { - "name": "added_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "last_reminder_sent_at": { - "name": "last_reminder_sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "cart_items_cart_id_fkey": { - "name": "cart_items_cart_id_fkey", - "tableFrom": "cart_items", - "tableTo": "carts", - "schemaTo": "public", - "columnsFrom": [ - "cart_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "cart_items_item_id_fkey": { - "name": "cart_items_item_id_fkey", - "tableFrom": "cart_items", - "tableTo": "items", - "schemaTo": "public", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "cart_items_item_id_key": { - "columns": [ - "item_id" - ], - "nullsNotDistinct": false, - "name": "cart_items_item_id_key" - } - }, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.carts": { - "name": "carts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "carts_customer_id_fkey": { - "name": "carts_customer_id_fkey", - "tableFrom": "carts", - "tableTo": "customers", - "schemaTo": "public", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "carts_customer_id_key": { - "columns": [ - "customer_id" - ], - "nullsNotDistinct": false, - "name": "carts_customer_id_key" - } - }, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.customer_tokens": { - "name": "customer_tokens", - "schema": "", - "columns": { - "token": { - "name": "token", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "customer_tokens_customer_id_fkey": { - "name": "customer_tokens_customer_id_fkey", - "tableFrom": "customer_tokens", - "tableTo": "customers", - "schemaTo": "public", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.checkouts": { - "name": "checkouts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "shipping_address_id": { - "name": "shipping_address_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "processor": { - "name": "processor", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "processor_order_id": { - "name": "processor_order_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "amount_cents": { - "name": "amount_cents", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "raw_event": { - "name": "raw_event", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "checkouts_customer_id_fkey": { - "name": "checkouts_customer_id_fkey", - "tableFrom": "checkouts", - "tableTo": "customers", - "schemaTo": "public", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "checkouts_shipping_address_id_fkey": { - "name": "checkouts_shipping_address_id_fkey", - "tableFrom": "checkouts", - "tableTo": "shipping_addresses", - "schemaTo": "public", - "columnsFrom": [ - "shipping_address_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.customer_sessions": { - "name": "customer_sessions", - "schema": "", - "columns": { - "token": { - "name": "token", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "customer_sessions_customer_id_fkey": { - "name": "customer_sessions_customer_id_fkey", - "tableFrom": "customer_sessions", - "tableTo": "customers", - "schemaTo": "public", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.customers": { - "name": "customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email_verified": { - "name": "email_verified", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "marketing_consent": { - "name": "marketing_consent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "marketing_consent_at": { - "name": "marketing_consent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "marketing_consent_text": { - "name": "marketing_consent_text", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "unsubscribe_token": { - "name": "unsubscribe_token", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "favorite_alerts": { - "name": "favorite_alerts", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "favorite_alerts_at": { - "name": "favorite_alerts_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "favorite_alerts_text": { - "name": "favorite_alerts_text", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "customers_disabled_at_idx": { - "name": "customers_disabled_at_idx", - "columns": [ - { - "expression": "disabled_at", - "asc": true, - "nulls": "last", - "opclass": "timestamptz_ops", - "isExpression": false - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "where": "(disabled_at IS NOT NULL)", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "customers_email_key": { - "columns": [ - "email" - ], - "nullsNotDistinct": false, - "name": "customers_email_key" - }, - "customers_unsubscribe_token_key": { - "columns": [ - "unsubscribe_token" - ], - "nullsNotDistinct": false, - "name": "customers_unsubscribe_token_key" - } - }, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.item_tags": { - "name": "item_tags", - "schema": "", - "columns": { - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "tag_id": { - "name": "tag_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "item_tags_tag_id_idx": { - "name": "item_tags_tag_id_idx", - "columns": [ - { - "expression": "tag_id", - "asc": true, - "nulls": "last", - "opclass": "int4_ops", - "isExpression": false - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "item_tags_item_id_fkey": { - "name": "item_tags_item_id_fkey", - "tableFrom": "item_tags", - "tableTo": "items", - "schemaTo": "public", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "item_tags_tag_id_fkey": { - "name": "item_tags_tag_id_fkey", - "tableFrom": "item_tags", - "tableTo": "tags", - "schemaTo": "public", - "columnsFrom": [ - "tag_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "item_tags_pkey": { - "name": "item_tags_pkey", - "columns": [ - "item_id", - "tag_id" - ] - } - }, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.favorites": { - "name": "favorites", - "schema": "", - "columns": { - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "favorites_item_id_idx": { - "name": "favorites_item_id_idx", - "columns": [ - { - "expression": "item_id", - "asc": true, - "nulls": "last", - "opclass": "int4_ops", - "isExpression": false - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "favorites_customer_id_fkey": { - "name": "favorites_customer_id_fkey", - "tableFrom": "favorites", - "tableTo": "customers", - "schemaTo": "public", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "favorites_item_id_fkey": { - "name": "favorites_item_id_fkey", - "tableFrom": "favorites", - "tableTo": "items", - "schemaTo": "public", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "favorites_pkey": { - "name": "favorites_pkey", - "columns": [ - "customer_id", - "item_id" - ] - } - }, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - }, - "public.checkout_items": { - "name": "checkout_items", - "schema": "", - "columns": { - "checkout_id": { - "name": "checkout_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "price_cents": { - "name": "price_cents", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "checkout_items_checkout_id_fkey": { - "name": "checkout_items_checkout_id_fkey", - "tableFrom": "checkout_items", - "tableTo": "checkouts", - "schemaTo": "public", - "columnsFrom": [ - "checkout_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "checkout_items_item_id_fkey": { - "name": "checkout_items_item_id_fkey", - "tableFrom": "checkout_items", - "tableTo": "items", - "schemaTo": "public", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "checkout_items_pkey": { - "name": "checkout_items_pkey", - "columns": [ - "checkout_id", - "item_id" - ] - } - }, - "uniqueConstraints": {}, - "checkConstraints": {}, - "policies": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0001_snapshot.json b/backend/drizzle/meta/0001_snapshot.json deleted file mode 100644 index 86fc8a5..0000000 --- a/backend/drizzle/meta/0001_snapshot.json +++ /dev/null @@ -1,1363 +0,0 @@ -{ - "id": "8023ec5b-dd3f-4cdb-bf4c-f8f0b81f0a33", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.admin_settings": { - "name": "admin_settings", - "schema": "", - "columns": { - "key": { - "name": "key", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "value": { - "name": "value", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.cart_items": { - "name": "cart_items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "cart_id": { - "name": "cart_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "added_at": { - "name": "added_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "last_reminder_sent_at": { - "name": "last_reminder_sent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "cart_items_cart_id_fkey": { - "name": "cart_items_cart_id_fkey", - "tableFrom": "cart_items", - "tableTo": "carts", - "columnsFrom": [ - "cart_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "cart_items_item_id_fkey": { - "name": "cart_items_item_id_fkey", - "tableFrom": "cart_items", - "tableTo": "items", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "cart_items_item_id_key": { - "name": "cart_items_item_id_key", - "nullsNotDistinct": false, - "columns": [ - "item_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.carts": { - "name": "carts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "carts_customer_id_fkey": { - "name": "carts_customer_id_fkey", - "tableFrom": "carts", - "tableTo": "customers", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "carts_customer_id_key": { - "name": "carts_customer_id_key", - "nullsNotDistinct": false, - "columns": [ - "customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.categories": { - "name": "categories", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "parent_id": { - "name": "parent_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "categories_child_name_uniq": { - "name": "categories_child_name_uniq", - "columns": [ - { - "expression": "parent_id", - "asc": true, - "isExpression": true, - "nulls": "last" - }, - { - "expression": "lower(name)", - "asc": true, - "isExpression": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "(parent_id IS NOT NULL)", - "concurrently": false, - "method": "btree", - "with": {} - }, - "categories_parent_id_idx": { - "name": "categories_parent_id_idx", - "columns": [ - { - "expression": "parent_id", - "isExpression": false, - "asc": true, - "nulls": "last", - "opclass": "int4_ops" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "categories_root_name_uniq": { - "name": "categories_root_name_uniq", - "columns": [ - { - "expression": "lower(name)", - "asc": true, - "isExpression": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "(parent_id IS NULL)", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "categories_parent_id_fkey": { - "name": "categories_parent_id_fkey", - "tableFrom": "categories", - "tableTo": "categories", - "columnsFrom": [ - "parent_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.checkout_items": { - "name": "checkout_items", - "schema": "", - "columns": { - "checkout_id": { - "name": "checkout_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "price_cents": { - "name": "price_cents", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "checkout_items_checkout_id_fkey": { - "name": "checkout_items_checkout_id_fkey", - "tableFrom": "checkout_items", - "tableTo": "checkouts", - "columnsFrom": [ - "checkout_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "checkout_items_item_id_fkey": { - "name": "checkout_items_item_id_fkey", - "tableFrom": "checkout_items", - "tableTo": "items", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "checkout_items_pkey": { - "name": "checkout_items_pkey", - "columns": [ - "checkout_id", - "item_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.checkouts": { - "name": "checkouts", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "shipping_address_id": { - "name": "shipping_address_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "processor": { - "name": "processor", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "processor_order_id": { - "name": "processor_order_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "amount_cents": { - "name": "amount_cents", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "raw_event": { - "name": "raw_event", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "checkouts_customer_id_fkey": { - "name": "checkouts_customer_id_fkey", - "tableFrom": "checkouts", - "tableTo": "customers", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "checkouts_shipping_address_id_fkey": { - "name": "checkouts_shipping_address_id_fkey", - "tableFrom": "checkouts", - "tableTo": "shipping_addresses", - "columnsFrom": [ - "shipping_address_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.customer_sessions": { - "name": "customer_sessions", - "schema": "", - "columns": { - "token": { - "name": "token", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "customer_sessions_customer_id_fkey": { - "name": "customer_sessions_customer_id_fkey", - "tableFrom": "customer_sessions", - "tableTo": "customers", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.customer_tokens": { - "name": "customer_tokens", - "schema": "", - "columns": { - "token": { - "name": "token", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "customer_tokens_customer_id_fkey": { - "name": "customer_tokens_customer_id_fkey", - "tableFrom": "customer_tokens", - "tableTo": "customers", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.customers": { - "name": "customers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "password_hash": { - "name": "password_hash", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email_verified": { - "name": "email_verified", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "marketing_consent": { - "name": "marketing_consent", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "marketing_consent_at": { - "name": "marketing_consent_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "marketing_consent_text": { - "name": "marketing_consent_text", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "unsubscribe_token": { - "name": "unsubscribe_token", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "favorite_alerts": { - "name": "favorite_alerts", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "favorite_alerts_at": { - "name": "favorite_alerts_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "favorite_alerts_text": { - "name": "favorite_alerts_text", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "customers_disabled_at_idx": { - "name": "customers_disabled_at_idx", - "columns": [ - { - "expression": "disabled_at", - "isExpression": false, - "asc": true, - "nulls": "last", - "opclass": "timestamptz_ops" - } - ], - "isUnique": false, - "where": "(disabled_at IS NOT NULL)", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "customers_email_key": { - "name": "customers_email_key", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - }, - "customers_unsubscribe_token_key": { - "name": "customers_unsubscribe_token_key", - "nullsNotDistinct": false, - "columns": [ - "unsubscribe_token" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.favorites": { - "name": "favorites", - "schema": "", - "columns": { - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "favorites_item_id_idx": { - "name": "favorites_item_id_idx", - "columns": [ - { - "expression": "item_id", - "isExpression": false, - "asc": true, - "nulls": "last", - "opclass": "int4_ops" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "favorites_customer_id_fkey": { - "name": "favorites_customer_id_fkey", - "tableFrom": "favorites", - "tableTo": "customers", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "favorites_item_id_fkey": { - "name": "favorites_item_id_fkey", - "tableFrom": "favorites", - "tableTo": "items", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "favorites_pkey": { - "name": "favorites_pkey", - "columns": [ - "customer_id", - "item_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.item_images": { - "name": "item_images", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "image_path": { - "name": "image_path", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "sort_order": { - "name": "sort_order", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "item_images_item_id_fkey": { - "name": "item_images_item_id_fkey", - "tableFrom": "item_images", - "tableTo": "items", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.item_tags": { - "name": "item_tags", - "schema": "", - "columns": { - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "tag_id": { - "name": "tag_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "item_tags_tag_id_idx": { - "name": "item_tags_tag_id_idx", - "columns": [ - { - "expression": "tag_id", - "isExpression": false, - "asc": true, - "nulls": "last", - "opclass": "int4_ops" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "item_tags_item_id_fkey": { - "name": "item_tags_item_id_fkey", - "tableFrom": "item_tags", - "tableTo": "items", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "item_tags_tag_id_fkey": { - "name": "item_tags_tag_id_fkey", - "tableFrom": "item_tags", - "tableTo": "tags", - "columnsFrom": [ - "tag_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "item_tags_pkey": { - "name": "item_tags_pkey", - "columns": [ - "item_id", - "tag_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.items": { - "name": "items", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "price_cents": { - "name": "price_cents", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "reserved_until": { - "name": "reserved_until", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "sold_at": { - "name": "sold_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "paypal_order_id": { - "name": "paypal_order_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "category_id": { - "name": "category_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "condition_note": { - "name": "condition_note", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "items_category_id_idx": { - "name": "items_category_id_idx", - "columns": [ - { - "expression": "category_id", - "isExpression": false, - "asc": true, - "nulls": "last", - "opclass": "int4_ops" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "items_category_id_fkey": { - "name": "items_category_id_fkey", - "tableFrom": "items", - "tableTo": "categories", - "columnsFrom": [ - "category_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.orders": { - "name": "orders", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "item_id": { - "name": "item_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "checkout_id": { - "name": "checkout_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "processor": { - "name": "processor", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "processor_order_id": { - "name": "processor_order_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "amount_cents": { - "name": "amount_cents", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "raw_event": { - "name": "raw_event", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "orders_item_id_fkey": { - "name": "orders_item_id_fkey", - "tableFrom": "orders", - "tableTo": "items", - "columnsFrom": [ - "item_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "orders_customer_id_fkey": { - "name": "orders_customer_id_fkey", - "tableFrom": "orders", - "tableTo": "customers", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "orders_checkout_id_fkey": { - "name": "orders_checkout_id_fkey", - "tableFrom": "orders", - "tableTo": "checkouts", - "columnsFrom": [ - "checkout_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pgmigrations": { - "name": "pgmigrations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "run_on": { - "name": "run_on", - "type": "timestamp", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.shipping_addresses": { - "name": "shipping_addresses", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "customer_id": { - "name": "customer_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "full_name": { - "name": "full_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "address_line1": { - "name": "address_line1", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "address_line2": { - "name": "address_line2", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "city": { - "name": "city", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "postal_code": { - "name": "postal_code", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "country": { - "name": "country", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'US'" - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "usps_validated": { - "name": "usps_validated", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "usps_standardized": { - "name": "usps_standardized", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "shipping_addresses_customer_id_fkey": { - "name": "shipping_addresses_customer_id_fkey", - "tableFrom": "shipping_addresses", - "tableTo": "customers", - "columnsFrom": [ - "customer_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.tags": { - "name": "tags", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "color": { - "name": "color", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "tags_name_uniq": { - "name": "tags_name_uniq", - "columns": [ - { - "expression": "lower(name)", - "asc": true, - "isExpression": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/_journal.json b/backend/drizzle/meta/_journal.json deleted file mode 100644 index 7813ec8..0000000 --- a/backend/drizzle/meta/_journal.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "7", - "dialect": "postgresql", - "entries": [ - { - "idx": 0, - "version": "7", - "when": 1787946791717, - "tag": "0000_sleepy_franklin_richards", - "breakpoints": true - }, - { - "idx": 1, - "version": "7", - "when": 1787946975565, - "tag": "0001_add_condition_note", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/backend/drizzle/relations.ts b/backend/drizzle/relations.ts deleted file mode 100644 index d2f3dcf..0000000 --- a/backend/drizzle/relations.ts +++ /dev/null @@ -1,150 +0,0 @@ -import { relations } from "drizzle-orm/relations"; -import { items, itemImages, customers, shippingAddresses, categories, orders, checkouts, carts, cartItems, customerTokens, customerSessions, itemTags, tags, favorites, checkoutItems } from "./schema"; - -export const itemImagesRelations = relations(itemImages, ({one}) => ({ - item: one(items, { - fields: [itemImages.itemId], - references: [items.id] - }), -})); - -export const itemsRelations = relations(items, ({one, many}) => ({ - itemImages: many(itemImages), - category: one(categories, { - fields: [items.categoryId], - references: [categories.id] - }), - orders: many(orders), - cartItems: many(cartItems), - itemTags: many(itemTags), - favorites: many(favorites), - checkoutItems: many(checkoutItems), -})); - -export const shippingAddressesRelations = relations(shippingAddresses, ({one, many}) => ({ - customer: one(customers, { - fields: [shippingAddresses.customerId], - references: [customers.id] - }), - checkouts: many(checkouts), -})); - -export const customersRelations = relations(customers, ({many}) => ({ - shippingAddresses: many(shippingAddresses), - orders: many(orders), - carts: many(carts), - customerTokens: many(customerTokens), - checkouts: many(checkouts), - customerSessions: many(customerSessions), - favorites: many(favorites), -})); - -export const categoriesRelations = relations(categories, ({one, many}) => ({ - items: many(items), - category: one(categories, { - fields: [categories.parentId], - references: [categories.id], - relationName: "categories_parentId_categories_id" - }), - categories: many(categories, { - relationName: "categories_parentId_categories_id" - }), -})); - -export const ordersRelations = relations(orders, ({one}) => ({ - item: one(items, { - fields: [orders.itemId], - references: [items.id] - }), - customer: one(customers, { - fields: [orders.customerId], - references: [customers.id] - }), - checkout: one(checkouts, { - fields: [orders.checkoutId], - references: [checkouts.id] - }), -})); - -export const checkoutsRelations = relations(checkouts, ({one, many}) => ({ - orders: many(orders), - customer: one(customers, { - fields: [checkouts.customerId], - references: [customers.id] - }), - shippingAddress: one(shippingAddresses, { - fields: [checkouts.shippingAddressId], - references: [shippingAddresses.id] - }), - checkoutItems: many(checkoutItems), -})); - -export const cartItemsRelations = relations(cartItems, ({one}) => ({ - cart: one(carts, { - fields: [cartItems.cartId], - references: [carts.id] - }), - item: one(items, { - fields: [cartItems.itemId], - references: [items.id] - }), -})); - -export const cartsRelations = relations(carts, ({one, many}) => ({ - cartItems: many(cartItems), - customer: one(customers, { - fields: [carts.customerId], - references: [customers.id] - }), -})); - -export const customerTokensRelations = relations(customerTokens, ({one}) => ({ - customer: one(customers, { - fields: [customerTokens.customerId], - references: [customers.id] - }), -})); - -export const customerSessionsRelations = relations(customerSessions, ({one}) => ({ - customer: one(customers, { - fields: [customerSessions.customerId], - references: [customers.id] - }), -})); - -export const itemTagsRelations = relations(itemTags, ({one}) => ({ - item: one(items, { - fields: [itemTags.itemId], - references: [items.id] - }), - tag: one(tags, { - fields: [itemTags.tagId], - references: [tags.id] - }), -})); - -export const tagsRelations = relations(tags, ({many}) => ({ - itemTags: many(itemTags), -})); - -export const favoritesRelations = relations(favorites, ({one}) => ({ - customer: one(customers, { - fields: [favorites.customerId], - references: [customers.id] - }), - item: one(items, { - fields: [favorites.itemId], - references: [items.id] - }), -})); - -export const checkoutItemsRelations = relations(checkoutItems, ({one}) => ({ - checkout: one(checkouts, { - fields: [checkoutItems.checkoutId], - references: [checkouts.id] - }), - item: one(items, { - fields: [checkoutItems.itemId], - references: [items.id] - }), -})); \ No newline at end of file diff --git a/backend/drizzle/schema.ts b/backend/drizzle/schema.ts deleted file mode 100644 index 5985a9b..0000000 --- a/backend/drizzle/schema.ts +++ /dev/null @@ -1,289 +0,0 @@ -import { pgTable, serial, varchar, timestamp, text, foreignKey, integer, boolean, jsonb, index, uniqueIndex, unique, primaryKey } from "drizzle-orm/pg-core" -import { sql } from "drizzle-orm" - - - -export const pgmigrations = pgTable("pgmigrations", { - id: serial().primaryKey().notNull(), - name: varchar({ length: 255 }).notNull(), - runOn: timestamp("run_on", { mode: 'string' }).notNull(), -}); - -export const adminSettings = pgTable("admin_settings", { - key: text().primaryKey().notNull(), - value: text().notNull(), - updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}); - -export const itemImages = pgTable("item_images", { - id: serial().primaryKey().notNull(), - itemId: integer("item_id").notNull(), - imagePath: text("image_path").notNull(), - sortOrder: integer("sort_order").default(0).notNull(), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - foreignKey({ - columns: [table.itemId], - foreignColumns: [items.id], - name: "item_images_item_id_fkey" - }).onDelete("cascade"), -]); - -export const shippingAddresses = pgTable("shipping_addresses", { - id: serial().primaryKey().notNull(), - customerId: integer("customer_id").notNull(), - fullName: text("full_name").notNull(), - addressLine1: text("address_line1").notNull(), - addressLine2: text("address_line2"), - city: text().notNull(), - state: text().notNull(), - postalCode: text("postal_code").notNull(), - country: text().default('US').notNull(), - isDefault: boolean("is_default").default(false).notNull(), - uspsValidated: boolean("usps_validated").default(false).notNull(), - uspsStandardized: jsonb("usps_standardized"), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - foreignKey({ - columns: [table.customerId], - foreignColumns: [customers.id], - name: "shipping_addresses_customer_id_fkey" - }).onDelete("cascade"), -]); - -export const items = pgTable("items", { - id: serial().primaryKey().notNull(), - name: text().notNull(), - description: text(), - priceCents: integer("price_cents").notNull(), - status: text().default('pending').notNull(), - reservedUntil: timestamp("reserved_until", { withTimezone: true, mode: 'string' }), - soldAt: timestamp("sold_at", { withTimezone: true, mode: 'string' }), - paypalOrderId: text("paypal_order_id"), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), - categoryId: integer("category_id"), -}, (table) => [ - index("items_category_id_idx").using("btree", table.categoryId.asc().nullsLast().op("int4_ops")), - foreignKey({ - columns: [table.categoryId], - foreignColumns: [categories.id], - name: "items_category_id_fkey" - }).onDelete("set null"), -]); - -export const tags = pgTable("tags", { - id: serial().primaryKey().notNull(), - name: text().notNull(), - color: text().notNull(), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - uniqueIndex("tags_name_uniq").using("btree", sql`lower(name)`), -]); - -export const categories = pgTable("categories", { - id: serial().primaryKey().notNull(), - name: text().notNull(), - parentId: integer("parent_id"), - sortOrder: integer("sort_order").default(0).notNull(), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - uniqueIndex("categories_child_name_uniq").using("btree", sql`parent_id`, sql`lower(name)`).where(sql`(parent_id IS NOT NULL)`), - index("categories_parent_id_idx").using("btree", table.parentId.asc().nullsLast().op("int4_ops")), - uniqueIndex("categories_root_name_uniq").using("btree", sql`lower(name)`).where(sql`(parent_id IS NULL)`), - foreignKey({ - columns: [table.parentId], - foreignColumns: [table.id], - name: "categories_parent_id_fkey" - }).onDelete("cascade"), -]); - -export const orders = pgTable("orders", { - id: serial().primaryKey().notNull(), - itemId: integer("item_id"), - customerId: integer("customer_id"), - checkoutId: integer("checkout_id"), - processor: text().notNull(), - processorOrderId: text("processor_order_id"), - amountCents: integer("amount_cents"), - status: text(), - rawEvent: jsonb("raw_event"), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - foreignKey({ - columns: [table.itemId], - foreignColumns: [items.id], - name: "orders_item_id_fkey" - }), - foreignKey({ - columns: [table.customerId], - foreignColumns: [customers.id], - name: "orders_customer_id_fkey" - }).onDelete("set null"), - foreignKey({ - columns: [table.checkoutId], - foreignColumns: [checkouts.id], - name: "orders_checkout_id_fkey" - }).onDelete("set null"), -]); - -export const cartItems = pgTable("cart_items", { - id: serial().primaryKey().notNull(), - cartId: integer("cart_id").notNull(), - itemId: integer("item_id").notNull(), - addedAt: timestamp("added_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), - expiresAt: timestamp("expires_at", { withTimezone: true, mode: 'string' }).notNull(), - lastReminderSentAt: timestamp("last_reminder_sent_at", { withTimezone: true, mode: 'string' }), -}, (table) => [ - foreignKey({ - columns: [table.cartId], - foreignColumns: [carts.id], - name: "cart_items_cart_id_fkey" - }).onDelete("cascade"), - foreignKey({ - columns: [table.itemId], - foreignColumns: [items.id], - name: "cart_items_item_id_fkey" - }).onDelete("cascade"), - unique("cart_items_item_id_key").on(table.itemId), -]); - -export const carts = pgTable("carts", { - id: serial().primaryKey().notNull(), - customerId: integer("customer_id").notNull(), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), - updatedAt: timestamp("updated_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - foreignKey({ - columns: [table.customerId], - foreignColumns: [customers.id], - name: "carts_customer_id_fkey" - }).onDelete("cascade"), - unique("carts_customer_id_key").on(table.customerId), -]); - -export const customerTokens = pgTable("customer_tokens", { - token: text().primaryKey().notNull(), - customerId: integer("customer_id").notNull(), - kind: text().notNull(), - expiresAt: timestamp("expires_at", { withTimezone: true, mode: 'string' }).notNull(), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - foreignKey({ - columns: [table.customerId], - foreignColumns: [customers.id], - name: "customer_tokens_customer_id_fkey" - }).onDelete("cascade"), -]); - -export const checkouts = pgTable("checkouts", { - id: serial().primaryKey().notNull(), - customerId: integer("customer_id"), - shippingAddressId: integer("shipping_address_id"), - processor: text().notNull(), - processorOrderId: text("processor_order_id"), - amountCents: integer("amount_cents"), - status: text().default('pending').notNull(), - rawEvent: jsonb("raw_event"), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - foreignKey({ - columns: [table.customerId], - foreignColumns: [customers.id], - name: "checkouts_customer_id_fkey" - }).onDelete("set null"), - foreignKey({ - columns: [table.shippingAddressId], - foreignColumns: [shippingAddresses.id], - name: "checkouts_shipping_address_id_fkey" - }).onDelete("set null"), -]); - -export const customerSessions = pgTable("customer_sessions", { - token: text().primaryKey().notNull(), - customerId: integer("customer_id").notNull(), - expiresAt: timestamp("expires_at", { withTimezone: true, mode: 'string' }).notNull(), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - foreignKey({ - columns: [table.customerId], - foreignColumns: [customers.id], - name: "customer_sessions_customer_id_fkey" - }).onDelete("cascade"), -]); - -export const customers = pgTable("customers", { - id: serial().primaryKey().notNull(), - email: text().notNull(), - passwordHash: text("password_hash").notNull(), - emailVerified: boolean("email_verified").default(false).notNull(), - marketingConsent: boolean("marketing_consent").default(false).notNull(), - marketingConsentAt: timestamp("marketing_consent_at", { withTimezone: true, mode: 'string' }), - marketingConsentText: text("marketing_consent_text"), - unsubscribeToken: text("unsubscribe_token").notNull(), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), - disabledAt: timestamp("disabled_at", { withTimezone: true, mode: 'string' }), - favoriteAlerts: boolean("favorite_alerts").default(false).notNull(), - favoriteAlertsAt: timestamp("favorite_alerts_at", { withTimezone: true, mode: 'string' }), - favoriteAlertsText: text("favorite_alerts_text"), - firstName: text("first_name"), - lastName: text("last_name"), -}, (table) => [ - index("customers_disabled_at_idx").using("btree", table.disabledAt.asc().nullsLast().op("timestamptz_ops")).where(sql`(disabled_at IS NOT NULL)`), - unique("customers_email_key").on(table.email), - unique("customers_unsubscribe_token_key").on(table.unsubscribeToken), -]); - -export const itemTags = pgTable("item_tags", { - itemId: integer("item_id").notNull(), - tagId: integer("tag_id").notNull(), -}, (table) => [ - index("item_tags_tag_id_idx").using("btree", table.tagId.asc().nullsLast().op("int4_ops")), - foreignKey({ - columns: [table.itemId], - foreignColumns: [items.id], - name: "item_tags_item_id_fkey" - }).onDelete("cascade"), - foreignKey({ - columns: [table.tagId], - foreignColumns: [tags.id], - name: "item_tags_tag_id_fkey" - }).onDelete("cascade"), - primaryKey({ columns: [table.itemId, table.tagId], name: "item_tags_pkey"}), -]); - -export const favorites = pgTable("favorites", { - customerId: integer("customer_id").notNull(), - itemId: integer("item_id").notNull(), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), -}, (table) => [ - index("favorites_item_id_idx").using("btree", table.itemId.asc().nullsLast().op("int4_ops")), - foreignKey({ - columns: [table.customerId], - foreignColumns: [customers.id], - name: "favorites_customer_id_fkey" - }).onDelete("cascade"), - foreignKey({ - columns: [table.itemId], - foreignColumns: [items.id], - name: "favorites_item_id_fkey" - }).onDelete("cascade"), - primaryKey({ columns: [table.customerId, table.itemId], name: "favorites_pkey"}), -]); - -export const checkoutItems = pgTable("checkout_items", { - checkoutId: integer("checkout_id").notNull(), - itemId: integer("item_id").notNull(), - priceCents: integer("price_cents").notNull(), -}, (table) => [ - foreignKey({ - columns: [table.checkoutId], - foreignColumns: [checkouts.id], - name: "checkout_items_checkout_id_fkey" - }).onDelete("cascade"), - foreignKey({ - columns: [table.itemId], - foreignColumns: [items.id], - name: "checkout_items_item_id_fkey" - }).onDelete("cascade"), - primaryKey({ columns: [table.checkoutId, table.itemId], name: "checkout_items_pkey"}), -]);