-- VILLAFLOW CMS — Migration 008
-- Phase 4 — Facilities
-- Owns: the reusable Facilities master list (name, icon, scope).
-- Does NOT own: room assignment (see 009_create_room_facilities.sql,
-- Phase 4F — the room_facilities pivot does not exist yet).

CREATE TABLE IF NOT EXISTS facilities (
    id            INT UNSIGNED    AUTO_INCREMENT PRIMARY KEY,
    name          VARCHAR(150)    NOT NULL,
    slug          VARCHAR(170)    NOT NULL,
    icon          VARCHAR(100)    NULL,
    scope         ENUM('room','property') NOT NULL,
    created_at    TIMESTAMP       NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at    TIMESTAMP       NOT NULL DEFAULT CURRENT_TIMESTAMP
                                  ON UPDATE CURRENT_TIMESTAMP,

    UNIQUE KEY uq_facilities_slug (slug)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
