-- Migrasi multi-outlet (jalankan SEKALI saja di phpMyAdmin untuk DB yang sudah ada)
CREATE TABLE IF NOT EXISTS outlets (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100) NOT NULL,
  address VARCHAR(255) 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 users ADD COLUMN outlet_id INT NULL;
ALTER TABLE orders ADD COLUMN outlet_id INT NULL;

INSERT INTO outlets (name, address, is_active)
SELECT 'Outlet 1', '', 1
WHERE NOT EXISTS (SELECT 1 FROM outlets WHERE name = 'Outlet 1');