freshyo/packages/db_helper_sqlite/drizzle/0007_addresses_bound_id.sql
2026-10-09 00:58:12 +05:30

11 lines
487 B
SQL

-- Migration: addresses.bound_id — the bound a saved address belongs to.
--
-- Every address is assigned to a bound; new addresses get the user's active
-- bound. Existing rows are backfilled to bound 1.
--
-- NOTE: SQLite has no ADD COLUMN IF NOT EXISTS; rely on the migration journal to
-- run this once.
ALTER TABLE `addresses` ADD COLUMN `bound_id` integer REFERENCES `region_bounds`(`id`);
--> statement-breakpoint
UPDATE `addresses` SET `bound_id` = 1 WHERE `bound_id` IS NULL;