CREATE TABLE "router_v1.7"."validations" (
	"offer_hash" varchar(66) PRIMARY KEY NOT NULL,
	"status_id" integer NOT NULL,
	"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
DELETE FROM "router_v1.7"."status" WHERE "code" = 'NOT_ENOUGH_LIQUIDITY';--> statement-breakpoint
DROP TABLE "router_v1.7"."offer_status" CASCADE;--> statement-breakpoint
ALTER TABLE "router_v1.7"."status" ALTER COLUMN "code" SET DATA TYPE text;--> statement-breakpoint
UPDATE "router_v1.7"."status" SET "code" = 'SIMULATION_ERROR' WHERE "code" = 'NOT_ENOUGH_LIQUIDITY';--> statement-breakpoint
DROP TYPE "router_v1.7"."status_code";--> statement-breakpoint
CREATE TYPE "router_v1.7"."status_code" AS ENUM('VALID', 'SIMULATION_ERROR');--> statement-breakpoint
ALTER TABLE "router_v1.7"."status" ALTER COLUMN "code" SET DATA TYPE "router_v1.7"."status_code" USING "code"::"router_v1.7"."status_code";--> statement-breakpoint
ALTER TABLE "router_v1.7"."validations" ADD CONSTRAINT "validations_offer_hash_offers_v2_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "router_v1.7"."offers_v2"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "router_v1.7"."validations" ADD CONSTRAINT "validations_status_id_status_id_fk" FOREIGN KEY ("status_id") REFERENCES "router_v1.7"."status"("id") ON DELETE no action ON UPDATE no action;
