CREATE TABLE IF NOT EXISTS payment_methods (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(120) NOT NULL,
    account_name VARCHAR(120) NOT NULL,
    account_number VARCHAR(80) NOT NULL,
    instructions TEXT,
    is_active TINYINT(1) NOT NULL DEFAULT 1,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
    INDEX idx_payment_methods_active (is_active)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Contoh data default (Hanya akan diinsert jika tabel kosong)
INSERT INTO payment_methods (name, account_name, account_number, instructions, is_active)
SELECT 'Transfer Bank Syariah', 'Al-Qanuni Store', '1234567890', 'Silakan transfer sesuai total dan unggah bukti pembayaran.', 1
WHERE NOT EXISTS (SELECT 1 FROM payment_methods LIMIT 1);
