-- Client portal auth + cancel/reschedule policy
USE BarberShop;

CREATE TABLE IF NOT EXISTS client_policy (
    tenant_id INT PRIMARY KEY,
    notice_hours INT NOT NULL DEFAULT 24,
    cancel_fee DECIMAL(10,2) NOT NULL DEFAULT 25.00,
    allow_reschedule TINYINT(1) NOT NULL DEFAULT 1,
    allow_cancel TINYINT(1) NOT NULL DEFAULT 1,
    fee_note VARCHAR(255) DEFAULT 'A cancellation fee may apply if changed within the notice window.',
    FOREIGN KEY (tenant_id) REFERENCES tenants(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO client_policy (tenant_id, notice_hours, cancel_fee, allow_reschedule, allow_cancel, fee_note)
VALUES (1, 24, 25.00, 1, 1, 'Changes within 24 hours may incur a $25 fee (collected at the shop until online payments are enabled).')
ON DUPLICATE KEY UPDATE notice_hours = VALUES(notice_hours);
