-- Migrasi: Kode Usaha (business_codes) untuk filter menu per jenis usaha
-- Jalankan di phpMyAdmin SEKALI saja

CREATE TABLE IF NOT EXISTS business_codes (
  id INT AUTO_INCREMENT PRIMARY KEY,
  code VARCHAR(50) NOT NULL UNIQUE,
  name VARCHAR(100) NOT NULL,
  is_active TINYINT NOT NULL DEFAULT 1,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE products ADD COLUMN kode_usaha VARCHAR(50) NULL;

INSERT INTO business_codes (code, name) VALUES
('CHICKEN', 'Ayam & Chicken'),
('COFFEE', 'Kopi & Minuman'),
('BAKSO', 'Bakso & Mie')
ON DUPLICATE KEY UPDATE name = VALUES(name);
