ALTER TABLE "tags" DROP CONSTRAINT "contract_item_tag_no_unique";--> statement-breakpoint
ALTER TABLE "code_groups" DROP CONSTRAINT "code_groups_group_id_unique";--> statement-breakpoint
ALTER TABLE "document_classes" DROP CONSTRAINT "document_classes_code_unique";--> statement-breakpoint
ALTER TABLE "document_classes" DROP CONSTRAINT "document_classes_value_unique";--> statement-breakpoint
ALTER TABLE "document_number_types" DROP CONSTRAINT "document_number_types_name_unique";--> statement-breakpoint
ALTER TABLE "tags" ADD COLUMN "tag_idx" varchar(100) NOT NULL;--> statement-breakpoint
ALTER TABLE "code_groups" ADD COLUMN "project_id" integer NOT NULL;--> statement-breakpoint
ALTER TABLE "combo_box_settings" ADD COLUMN "project_id" integer NOT NULL;--> statement-breakpoint
ALTER TABLE "document_classes" ADD COLUMN "project_id" integer NOT NULL;--> statement-breakpoint
ALTER TABLE "document_number_type_configs" ADD COLUMN "project_id" integer NOT NULL;--> statement-breakpoint
ALTER TABLE "document_number_types" ADD COLUMN "project_id" integer NOT NULL;--> statement-breakpoint
ALTER TABLE "code_groups" ADD CONSTRAINT "code_groups_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "combo_box_settings" ADD CONSTRAINT "combo_box_settings_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "document_classes" ADD CONSTRAINT "document_classes_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "document_number_type_configs" ADD CONSTRAINT "document_number_type_configs_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "document_number_types" ADD CONSTRAINT "document_number_types_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tags" ADD CONSTRAINT "contract_item_tag_idx_unique" UNIQUE("contract_item_id","tag_idx");--> statement-breakpoint
ALTER TABLE "code_groups" ADD CONSTRAINT "unique_project_group_id" UNIQUE("project_id","group_id");--> statement-breakpoint
ALTER TABLE "combo_box_settings" ADD CONSTRAINT "unique_project_code_group_code" UNIQUE("project_id","code_group_id","code");--> statement-breakpoint
ALTER TABLE "document_classes" ADD CONSTRAINT "unique_project_code" UNIQUE("project_id","code");--> statement-breakpoint
ALTER TABLE "document_classes" ADD CONSTRAINT "unique_project_value" UNIQUE("project_id","value");--> statement-breakpoint
ALTER TABLE "document_number_type_configs" ADD CONSTRAINT "unique_project_number_type_sdq" UNIQUE("project_id","document_number_type_id","sdq");--> statement-breakpoint
ALTER TABLE "document_number_types" ADD CONSTRAINT "unique_project_name" UNIQUE("project_id","name");