{
  "stmt": "-- Migration: Remove room_number column and add unique index on date + room_id\n-- This migration removes the duplicate room_number column and adds a unique constraint\n-- to prevent duplicate check-ins for the same room on the same day\n\n-- Step 1: Delete existing unique index if it exists (for safety)\nDROP INDEX IF EXISTS date_room_idx ON daily_checkins;\n\n-- Step 2: Add unique index on date + room_id\n-- This physically prevents creating two check-ins for the same room on the same day\nCREATE UNIQUE INDEX date_room_idx ON daily_checkins (date, room_id);\n\n-- Step 3: Drop the room_number column (it's now redundant with room_id)\nALTER TABLE daily_checkins DROP COLUMN room_number;\n\n-- Step 4: Update room_id column to be NOT NULL (all existing records should have room_id)\n-- First, ensure all records have room_id (should be true from snapshots)\nUPDATE daily_checkins SET room_id = SUBSTRING(id, 1, 10) WHERE room_id IS NULL;\n\n-- Then, make the column NOT NULL\nALTER TABLE daily_checkins MODIFY COLUMN room_id VARCHAR(10) NOT NULL;\n"
}