-- Migration to add multi-currency pricing support for drops -- Date: 2025-01-XX -- Adds support for CHF and EUR prices, both regular and wholesale SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; -- Add price columns to drops table -- Prices are stored as decimal per gram ALTER TABLE `drops` ADD COLUMN `price_chf` decimal(10,4) DEFAULT NULL AFTER `ppu`, ADD COLUMN `price_eur` decimal(10,4) DEFAULT NULL AFTER `price_chf`, ADD COLUMN `wholesale_price_chf` decimal(10,4) DEFAULT NULL AFTER `price_eur`, ADD COLUMN `wholesale_price_eur` decimal(10,4) DEFAULT NULL AFTER `wholesale_price_chf`; -- Migrate existing ppu data to new price fields -- ppu is stored as integer where 1000 = 1.00 EUR per gram -- Convert to decimal format and set both EUR and CHF prices UPDATE `drops` SET `price_eur` = `ppu` / 1000.0, `price_chf` = (`ppu` / 1000.0) * 0.97, -- Convert EUR to CHF (1 EUR ≈ 0.97 CHF) `wholesale_price_eur` = (`ppu` / 1000.0) * 0.76, -- 76% of regular price `wholesale_price_chf` = (`ppu` / 1000.0) * 0.76 * 0.97 -- 76% of regular price in CHF WHERE `ppu` IS NOT NULL AND `ppu` > 0; COMMIT;