-- ALTER za dodavanje automobil_id i uredjaj_id u offer_items tablicu
-- i radni_nalog_id u offers tablicu
-- Izvršite ručno u phpMyAdmin ili MySQL klijentu

-- 1. Dodaj polja u offer_items
ALTER TABLE `offer_items` 
ADD COLUMN `automobil_id` INT(11) NULL DEFAULT NULL AFTER `price_sell`,
ADD COLUMN `uredjaj_id` INT(11) NULL DEFAULT NULL AFTER `automobil_id`;

-- 2. Dodaj radni_nalog_id u offers tablicu za praćenje veze
ALTER TABLE `offers` 
ADD COLUMN `radni_nalog_id` INT(11) NULL DEFAULT NULL AFTER `customer_id`;

-- Opcijski: dodaj foreign key constraints
-- ALTER TABLE `offer_items` 
-- ADD CONSTRAINT `fk_offer_items_automobil` FOREIGN KEY (`automobil_id`) REFERENCES `automobil`(`id`) ON DELETE SET NULL,
-- ADD CONSTRAINT `fk_offer_items_uredjaj` FOREIGN KEY (`uredjaj_id`) REFERENCES `uredjaj`(`id`) ON DELETE SET NULL;

-- ALTER TABLE `offers`
-- ADD CONSTRAINT `fk_offers_radni_nalog` FOREIGN KEY (`radni_nalog_id`) REFERENCES `radni_nalog`(`id`) ON DELETE SET NULL;
