-- 004_create_services_table.sql
CREATE TABLE IF NOT EXISTS `services` (
    `id`                BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `nha_tro_id`        BIGINT UNSIGNED NOT NULL,
    `ten_dich_vu`       VARCHAR(100) NOT NULL,
    `don_vi`            VARCHAR(20) NOT NULL DEFAULT 'thang' COMMENT 'kWh|m3|thang|chiec',
    `don_gia`           DECIMAL(15,2) NOT NULL DEFAULT 0.00,
    `loai_tinh_phi`     ENUM('theo_dong_ho','co_dinh') NOT NULL DEFAULT 'co_dinh',
    `ap_dung_bac_thang` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 = áp dụng bậc thang EVN',
    `dang_hoat_dong`    TINYINT(1) NOT NULL DEFAULT 1,
    `created_at`        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at`        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `services_nha_tro_id_index` (`nha_tro_id`),
    CONSTRAINT `fk_services_nha_tro`
        FOREIGN KEY (`nha_tro_id`) REFERENCES `properties` (`id`) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
