/*
 Navicat Premium Dump SQL

 Source Server         : FnOS 80
 Source Server Type    : PostgreSQL
 Source Server Version : 150017 (150017)
 Source Host           : 10.8.8.80:5434
 Source Catalog        : log_platform
 Source Schema         : room_status

 Target Server Type    : PostgreSQL
 Target Server Version : 150017 (150017)
 File Encoding         : 65001

 Date: 10/03/2026 10:32:13
*/


-- ----------------------------
-- Table structure for room_status_moment_g5
-- ----------------------------
DROP TABLE IF EXISTS "room_status"."room_status_moment_g5";
CREATE TABLE "room_status"."room_status_moment_g5" (
  "hotel_id" int2 NOT NULL,
  "room_id" text COLLATE "pg_catalog"."default" NOT NULL,
  "device_id" text COLLATE "pg_catalog"."default" NOT NULL,
  "ts_ms" int8 NOT NULL DEFAULT ((EXTRACT(epoch FROM clock_timestamp()) * (1000)::numeric))::bigint,
  "sys_lock_status" int2,
  "online_status" int2,
  "launcher_version" text COLLATE "pg_catalog"."default",
  "app_version" text COLLATE "pg_catalog"."default",
  "config_version" text COLLATE "pg_catalog"."default",
  "register_ts_ms" int8,
  "upgrade_ts_ms" int8,
  "config_ts_ms" int8,
  "ip" text COLLATE "pg_catalog"."default",
  "pms_status" int2,
  "power_state" int2,
  "cardless_state" int2,
  "service_mask" int8,
  "insert_card" int2,
  "bright_g" int2,
  "agreement_ver" text COLLATE "pg_catalog"."default",
  "air_address" _text COLLATE "pg_catalog"."default",
  "air_state" _int2,
  "air_model" _int2,
  "air_speed" _int2,
  "air_set_temp" _int2,
  "air_now_temp" _int2,
  "air_solenoid_valve" _int2,
  "elec_address" _text COLLATE "pg_catalog"."default",
  "elec_voltage" _float8,
  "elec_ampere" _float8,
  "elec_power" _float8,
  "elec_phase" _float8,
  "elec_energy" _float8,
  "elec_sum_energy" _float8,
  "carbon_state" int2,
  "dev_loops" jsonb,
  "energy_carbon_sum" float8,
  "energy_nocard_sum" float8,
  "external_device" jsonb DEFAULT '{}'::jsonb,
  "faulty_device_count" jsonb DEFAULT '{}'::jsonb
)
WITH (fillfactor=90)
TABLESPACE "ts_hot"
;

-- ----------------------------
-- Indexes structure for table room_status_moment_g5
-- ----------------------------
CREATE INDEX "idx_rsm_g5_dashboard_query" ON "room_status"."room_status_moment_g5" USING btree (
  "hotel_id" "pg_catalog"."int2_ops" ASC NULLS LAST,
  "online_status" "pg_catalog"."int2_ops" ASC NULLS LAST,
  "power_state" "pg_catalog"."int2_ops" ASC NULLS LAST
);

-- ----------------------------
-- Triggers structure for table room_status_moment_g5
-- ----------------------------
CREATE TRIGGER "trg_update_rsm_ts_ms" BEFORE UPDATE ON "room_status"."room_status_moment_g5"
FOR EACH ROW
EXECUTE PROCEDURE "room_status"."update_ts_ms_g5"();

-- ----------------------------
-- Primary Key structure for table room_status_moment_g5
-- ----------------------------
ALTER TABLE "room_status"."room_status_moment_g5" ADD CONSTRAINT "room_status_moment_g5_pkey" PRIMARY KEY ("hotel_id", "room_id");
