bookwiz.io / supabase / migrations / 037_fix_gpt_image_constraints.sql
037_fix_gpt_image_constraints.sql
Raw
-- Fix constraints for GPT Image 1 compatibility
-- GPT Image 1 has different parameters compared to DALL-E 3

-- 1. Remove style constraint since GPT Image 1 doesn't use style parameter
ALTER TABLE generated_images 
DROP CONSTRAINT generated_images_style_check;

-- 2. Make style column nullable since GPT Image 1 doesn't use it
ALTER TABLE generated_images 
ALTER COLUMN style DROP NOT NULL;

-- 3. Update default values for GPT Image 1
ALTER TABLE generated_images 
ALTER COLUMN model SET DEFAULT 'gpt-image-1';

ALTER TABLE generated_images 
ALTER COLUMN style SET DEFAULT NULL;

-- 4. Update comments to reflect the changes
COMMENT ON COLUMN generated_images.model IS 'AI model used for generation (e.g., gpt-image-1, dall-e-3)';
COMMENT ON COLUMN generated_images.style IS 'Style parameter for models that support it (DALL-E 3: natural/vivid, GPT Image 1: not used)';
COMMENT ON COLUMN generated_images.quality IS 'Quality setting (GPT Image 1: low/medium/high/auto, DALL-E 3: standard/hd)';