Files
red/teressa-copeland-homes/drizzle/0001_watery_blindfold.sql

19 lines
774 B
MySQL
Raw Normal View History

CREATE TYPE "public"."document_status" AS ENUM('Draft', 'Sent', 'Viewed', 'Signed');--> statement-breakpoint
CREATE TABLE "clients" (
"id" text PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"email" text NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "documents" (
"id" text PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"client_id" text NOT NULL,
"status" "document_status" DEFAULT 'Draft' NOT NULL,
"sent_at" timestamp,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "documents" ADD CONSTRAINT "documents_client_id_clients_id_fk" FOREIGN KEY ("client_id") REFERENCES "public"."clients"("id") ON DELETE cascade ON UPDATE no action;