diff --git a/backend/src/db/migrations/0001_add_strips.sql b/backend/src/db/migrations/0001_add_strips.sql index 5b29501..d02b0ff 100644 --- a/backend/src/db/migrations/0001_add_strips.sql +++ b/backend/src/db/migrations/0001_add_strips.sql @@ -1 +1,3 @@ -ALTER TABLE medications ADD COLUMN strips integer NOT NULL DEFAULT 0; +-- Migration 0001: strips column already exists in 0000_init.sql +-- This file is kept for migration history compatibility +SELECT 1; diff --git a/backend/src/db/migrations/0002_pack_inventory.sql b/backend/src/db/migrations/0002_pack_inventory.sql index bac4e38..a24547c 100644 --- a/backend/src/db/migrations/0002_pack_inventory.sql +++ b/backend/src/db/migrations/0002_pack_inventory.sql @@ -1,15 +1,3 @@ -ALTER TABLE medications ADD COLUMN pack_count integer NOT NULL DEFAULT 1; -ALTER TABLE medications ADD COLUMN strips_per_pack integer NOT NULL DEFAULT 1; -ALTER TABLE medications ADD COLUMN tabs_per_strip integer NOT NULL DEFAULT 1; -ALTER TABLE medications ADD COLUMN loose_tablets integer NOT NULL DEFAULT 0; - --- Backfill from previous fields where possible -UPDATE medications -SET - pack_count = COALESCE(pack_count, 1), - strips_per_pack = CASE WHEN strips IS NOT NULL THEN strips ELSE 1 END, - tabs_per_strip = CASE WHEN strip_size IS NOT NULL THEN strip_size ELSE 1 END, - loose_tablets = CASE - WHEN strip_size IS NOT NULL AND strips IS NOT NULL THEN MAX(count - (strips * strip_size), 0) - ELSE 0 - END; +-- Migration 0002: pack inventory columns already exist in 0000_init.sql +-- This file is kept for migration history compatibility +SELECT 1;