From f4225d0334bc1a54fa67d13ebdae9816b82f1898 Mon Sep 17 00:00:00 2001 From: Marko Djordjevic Date: Fri, 20 Feb 2026 09:50:08 +0100 Subject: [PATCH] Generate Drizzle migration with user accounts schema changes --- drizzle/0001_daffy_zaladane.sql | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 drizzle/0001_daffy_zaladane.sql diff --git a/drizzle/0001_daffy_zaladane.sql b/drizzle/0001_daffy_zaladane.sql new file mode 100644 index 0000000..4c1bdee --- /dev/null +++ b/drizzle/0001_daffy_zaladane.sql @@ -0,0 +1,30 @@ +CREATE TABLE "users" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "email" text NOT NULL, + "password_hash" text, + "name" text, + "image" text, + "provider" text DEFAULT 'credentials' NOT NULL, + "provider_account_id" text, + "email_verified" timestamp, + "created_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL, + CONSTRAINT "users_email_unique" UNIQUE("email") +); +--> statement-breakpoint +ALTER TABLE "annotation_types" DROP CONSTRAINT "annotation_types_name_unique";--> statement-breakpoint +ALTER TABLE "charts" DROP CONSTRAINT "charts_name_unique";--> statement-breakpoint +ALTER TABLE "span_label_types" DROP CONSTRAINT "span_label_types_name_unique";--> statement-breakpoint +ALTER TABLE "annotation_types" ADD COLUMN "user_id" uuid;--> statement-breakpoint +ALTER TABLE "annotations" ADD COLUMN "user_id" uuid;--> statement-breakpoint +ALTER TABLE "charts" ADD COLUMN "user_id" uuid;--> statement-breakpoint +ALTER TABLE "span_annotations" ADD COLUMN "user_id" uuid;--> statement-breakpoint +ALTER TABLE "span_label_types" ADD COLUMN "user_id" uuid;--> statement-breakpoint +ALTER TABLE "annotation_types" ADD CONSTRAINT "annotation_types_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "annotations" ADD CONSTRAINT "annotations_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "charts" ADD CONSTRAINT "charts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "span_annotations" ADD CONSTRAINT "span_annotations_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "span_label_types" ADD CONSTRAINT "span_label_types_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "annotation_types_user_id_name_unique" ON "annotation_types" USING btree ("user_id","name");--> statement-breakpoint +CREATE UNIQUE INDEX "charts_user_id_name_unique" ON "charts" USING btree ("user_id","name");--> statement-breakpoint +CREATE UNIQUE INDEX "span_label_types_user_id_name_unique" ON "span_label_types" USING btree ("user_id","name"); \ No newline at end of file