ALTER TABLE "router_v1.7"."offers_v2" RENAME TO "offers";--> statement-breakpoint
ALTER TABLE "router_v1.7"."offers_callbacks" DROP CONSTRAINT "offers_callbacks_offer_hash_offers_v2_hash_fk";
--> statement-breakpoint
ALTER TABLE "router_v1.7"."offers" DROP CONSTRAINT "offers_v2_obligation_id_obligations_obligation_id_fk";
--> statement-breakpoint
ALTER TABLE "router_v1.7"."offers" DROP CONSTRAINT "offers_v2_groups_fk";
--> statement-breakpoint
ALTER TABLE "router_v1.7"."validations" DROP CONSTRAINT "validations_offer_hash_offers_v2_hash_fk";
--> statement-breakpoint
DROP INDEX "router_v1.7"."offers_v2_group_fk_idx";--> statement-breakpoint
DROP INDEX "router_v1.7"."offers_v2_group_and_hash_idx";--> statement-breakpoint
DROP INDEX "router_v1.7"."offers_v2_group_winner_sell_side_idx";--> statement-breakpoint
DROP INDEX "router_v1.7"."offers_v2_group_winner_buy_side_idx";--> statement-breakpoint
DROP INDEX "router_v1.7"."offers_v2_obligation_id_side_idx";--> statement-breakpoint
ALTER TABLE "router_v1.7"."offers_callbacks" ADD CONSTRAINT "offers_callbacks_offer_hash_offers_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "router_v1.7"."offers"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "router_v1.7"."offers" ADD CONSTRAINT "offers_obligation_id_obligations_obligation_id_fk" FOREIGN KEY ("obligation_id") REFERENCES "router_v1.7"."obligations"("obligation_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "router_v1.7"."offers" ADD CONSTRAINT "offers_groups_fk" FOREIGN KEY ("group_chain_id","group_maker","group_group") REFERENCES "router_v1.7"."groups"("chain_id","maker","group") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "router_v1.7"."validations" ADD CONSTRAINT "validations_offer_hash_offers_hash_fk" FOREIGN KEY ("offer_hash") REFERENCES "router_v1.7"."offers"("hash") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "offers_group_fk_idx" ON "router_v1.7"."offers" USING btree ("group_chain_id","group_maker","group_group");--> statement-breakpoint
CREATE INDEX "offers_group_and_hash_idx" ON "router_v1.7"."offers" USING btree ("group_chain_id","group_maker","group_group","hash");--> statement-breakpoint
CREATE INDEX "offers_group_winner_sell_side_idx" ON "router_v1.7"."offers" USING btree ("group_chain_id","group_maker","group_group","rate" desc,"block_number" asc,"assets" desc,"hash" asc);--> statement-breakpoint
CREATE INDEX "offers_group_winner_buy_side_idx" ON "router_v1.7"."offers" USING btree ("group_chain_id","group_maker","group_group","rate" asc,"block_number" asc,"assets" desc,"hash" asc);--> statement-breakpoint
CREATE INDEX "offers_obligation_id_side_idx" ON "router_v1.7"."offers" USING btree ("obligation_id","buy");