CREATE TABLE "tag_types" (
	"code" varchar(50) PRIMARY KEY NOT NULL,
	"description" text NOT NULL,
	"created_at" timestamp with time zone DEFAULT now() NOT NULL,
	"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "tag_subfields" DROP CONSTRAINT "tag_subfields_tag_type_code_unique";--> statement-breakpoint
ALTER TABLE "tag_classes" DROP CONSTRAINT "tag_classes_tag_type_code_tag_subfields_tag_type_code_fk";
--> statement-breakpoint
ALTER TABLE "tag_classes" ALTER COLUMN "id" SET DATA TYPE serial;--> statement-breakpoint
ALTER TABLE "tag_classes" ALTER COLUMN "id" DROP IDENTITY;--> statement-breakpoint
ALTER TABLE "tag_classes" ADD CONSTRAINT "tag_classes_tag_type_code_tag_types_code_fk" FOREIGN KEY ("tag_type_code") REFERENCES "public"."tag_types"("code") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tag_subfields" ADD CONSTRAINT "tag_subfields_tag_type_code_tag_types_code_fk" FOREIGN KEY ("tag_type_code") REFERENCES "public"."tag_types"("code") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tag_subfields" DROP COLUMN "tag_type_description";