-- Add new columns start_price and expiry_price
ALTER TABLE "router_v1.7"."offers"
  ADD COLUMN "start_price" numeric(78, 0),
  ADD COLUMN "expiry_price" numeric(78, 0);--> statement-breakpoint
-- Migrate data from rate to start_price and expiry_price
UPDATE "router_v1.7"."offers" SET start_price = rate, expiry_price = rate;--> statement-breakpoint
-- Make columns NOT NULL after migration
ALTER TABLE "router_v1.7"."offers"
  ALTER COLUMN "start_price" SET NOT NULL,
  ALTER COLUMN "expiry_price" SET NOT NULL;--> statement-breakpoint
-- Drop the old rate column
ALTER TABLE "router_v1.7"."offers" DROP COLUMN "rate";--> statement-breakpoint
-- Drop rate-based indexes (can't index computed values)
DROP INDEX IF EXISTS "router_v1.7"."offers_group_winner_sell_side_idx";--> statement-breakpoint
DROP INDEX IF EXISTS "router_v1.7"."offers_group_winner_buy_side_idx";
