-- Migration: Add new Bambu Lab PLA Matte and PLA Wood colors (2025)
-- This migration adds the new color offerings from Bambu Lab

-- Add new PLA Matte colors to the colors table
INSERT INTO colors (name, hex) VALUES
    ('Matte Apple Green', '#C6E188'),
    ('Matte Bone White', '#C8C5B6'),
    ('Matte Caramel', '#A4845C'),
    ('Matte Dark Blue', '#042F56'),
    ('Matte Dark Brown', '#7D6556'),
    ('Matte Dark Chocolate', '#4A3729'),
    ('Matte Dark Green', '#68724D'),
    ('Matte Dark Red', '#BB3D43'),
    ('Matte Grass Green', '#7CB342'),
    ('Matte Ice Blue', '#A3D8E1'),
    ('Matte Lemon Yellow', '#F7D959'),
    ('Matte Lilac Purple', '#AE96D4'),
    ('Matte Plum', '#851A52'),
    ('Matte Sakura Pink', '#E8AFCF'),
    ('Matte Sky Blue', '#73B2E5'),
    ('Matte Terracotta', '#A25A37')
ON CONFLICT (name)
DO UPDATE SET hex = EXCLUDED.hex;

-- Add new PLA Wood colors to the colors table
INSERT INTO colors (name, hex) VALUES
    ('Ochre Yellow', '#BC8B39'),
    ('White Oak', '#D2CCA2'),
    ('Clay Brown', '#8E621A')
ON CONFLICT (name)
DO UPDATE SET hex = EXCLUDED.hex;

-- Add PLA Matte filaments (all Refill only - 1 refill each, 0 spool)
INSERT INTO filaments (tip, finish, boja, refill, spulna, kolicina, cena)
SELECT
    'PLA' as tip,
    'Matte' as finish,
    c.name as boja,
    1 as refill,
    0 as spulna,
    1 as kolicina,
    '3499' as cena
FROM colors c
WHERE c.name IN (
    'Matte Apple Green', 'Matte Bone White', 'Matte Caramel',
    'Matte Dark Blue', 'Matte Dark Brown', 'Matte Dark Chocolate',
    'Matte Dark Green', 'Matte Dark Red', 'Matte Grass Green',
    'Matte Ice Blue', 'Matte Lemon Yellow', 'Matte Lilac Purple',
    'Matte Plum', 'Matte Sakura Pink', 'Matte Sky Blue', 'Matte Terracotta'
)
AND NOT EXISTS (
    SELECT 1 FROM filaments f
    WHERE f.tip = 'PLA'
    AND f.finish = 'Matte'
    AND f.boja = c.name
);

-- Add PLA Wood filaments (all Spool only - 0 refill, 1 spool each)
INSERT INTO filaments (tip, finish, boja, refill, spulna, kolicina, cena)
SELECT
    'PLA' as tip,
    'Wood' as finish,
    c.name as boja,
    0 as refill,
    1 as spulna,
    1 as kolicina,
    '3999' as cena
FROM colors c
WHERE c.name IN (
    'Ochre Yellow', 'White Oak', 'Clay Brown'
)
AND NOT EXISTS (
    SELECT 1 FROM filaments f
    WHERE f.tip = 'PLA'
    AND f.finish = 'Wood'
    AND f.boja = c.name
);
