From d29d60f99547ddd895a2623a0a8e5102fe3e4b4d Mon Sep 17 00:00:00 2001 From: Lawrence Chen <54008264+lawrencecchen@users.noreply.github.com> Date: Tue, 1 Sep 2026 23:21:22 -0700 Subject: [PATCH] Make the Blaxel-removal migration apply on a fresh database The four UPDATEs compared an enum column to 'blaxel', a value added by an earlier migration. On a fresh database drizzle runs both in one transaction, and Postgres rejects the enum literal with "unsafe use of new value". Compare the text form instead. Existing databases are unaffected: the rewrite still targets the same rows. Claude-Session: https://claude.ai/code/session_01S7SVaoTDXVuXZKaN5QAwHc --- .../migration.sql | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web/db/migrations/20260901120000_remove_blaxel_vm_provider/migration.sql b/web/db/migrations/20260901120000_remove_blaxel_vm_provider/migration.sql index c9d18295e593..7599b1791382 100644 --- a/web/db/migrations/20260901120000_remove_blaxel_vm_provider/migration.sql +++ b/web/db/migrations/20260901120000_remove_blaxel_vm_provider/migration.sql @@ -12,11 +12,16 @@ -- rows readable rather than dropping them. Run the reaper to destroy live -- Blaxel machines BEFORE applying this migration — afterwards nothing in the -- control plane can address them. +-- +-- The comparisons cast to text on purpose: on a fresh database every migration +-- runs in one transaction, and Postgres refuses to use an enum value added +-- earlier in that same transaction ("unsafe use of new value"). Comparing the +-- text form sidesteps the enum lookup and works on fresh and existing databases. -UPDATE "cloud_vms" SET "provider" = 'e2b' WHERE "provider" = 'blaxel'; -UPDATE "cloud_vm_usage_events" SET "provider" = 'e2b' WHERE "provider" = 'blaxel'; -UPDATE "cloud_vm_bases" SET "active_provider" = 'e2b' WHERE "active_provider" = 'blaxel'; -UPDATE "cloud_vm_base_generations" SET "provider" = 'e2b' WHERE "provider" = 'blaxel'; +UPDATE "cloud_vms" SET "provider" = 'e2b' WHERE "provider"::text = 'blaxel'; +UPDATE "cloud_vm_usage_events" SET "provider" = 'e2b' WHERE "provider"::text = 'blaxel'; +UPDATE "cloud_vm_bases" SET "active_provider" = 'e2b' WHERE "active_provider"::text = 'blaxel'; +UPDATE "cloud_vm_base_generations" SET "provider" = 'e2b' WHERE "provider"::text = 'blaxel'; ALTER TYPE "vm_provider" RENAME TO "vm_provider_old"; CREATE TYPE "vm_provider" AS ENUM ('e2b', 'freestyle', 'daytona');