feat: unify tasting form refactor & align db schema status levels
This commit is contained in:
11
migration_v2.sql
Normal file
11
migration_v2.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
-- 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'));
|
||||
Reference in New Issue
Block a user