Files
Dramlog-Prod/migration_v2.sql

12 lines
638 B
SQL

-- Run this in your Supabase SQL Editor if you have an older database version
-- 1. Add columns if they don't exist
ALTER TABLE bottles ADD COLUMN IF NOT EXISTS status TEXT DEFAULT 'sealed';
ALTER TABLE bottles ADD COLUMN IF NOT EXISTS purchase_price DECIMAL(10, 2);
ALTER TABLE bottles ADD COLUMN IF NOT EXISTS finished_at TIMESTAMP WITH TIME ZONE;
-- 2. Add check constraint for status
-- Note: We drop it first in case it exists with different values
ALTER TABLE bottles DROP CONSTRAINT IF EXISTS bottles_status_check;
ALTER TABLE bottles ADD CONSTRAINT bottles_status_check CHECK (status IN ('sealed', 'open', 'sampled', 'empty'));