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");