Files
be.ems/build/database/lite/upgrade/upg_alarm_event.sql
2025-07-15 18:53:04 +08:00

54 lines
2.2 KiB
SQL

-- ----------------------------
-- Table structure for alarm_event
-- ----------------------------
UPDATE "alarm_event" SET "alarm_status" = 'Clear' WHERE "alarm_status" = '0';
UPDATE "alarm_event" SET "alarm_status" = 'Active' WHERE "alarm_status" = '1';
UPDATE "alarm_event" SET "clear_type" = 'NotClear' WHERE "clear_type" = '0';
UPDATE "alarm_event" SET "clear_type" = 'AutoClear' WHERE "clear_type" = '1';
UPDATE "alarm_event" SET "clear_type" = 'ManualClear' WHERE "clear_type" = '2';
ALTER TABLE "alarm_event" RENAME TO "alarm_event_old";
CREATE TABLE "alarm_event" (
"id" integer NOT NULL,
"ne_type" text(32) NOT NULL,
"ne_id" text(64) NOT NULL,
"alarm_seq" integer(11),
"alarm_id" text(32) NOT NULL,
"alarm_title" text(255),
"alarm_code" integer(11),
"event_time" integer(20),
"object_uid" text(64),
"object_name" text(64),
"object_type" text(20),
"location_info" text(2048),
"alarm_status" text(64),
"specific_problem" text(255),
"specific_problem_id" text(100),
"add_info" text(2048),
"clear_type" text(64),
"clear_time" integer(20),
"clear_user" text(64),
"timestamp" integer(20),
PRIMARY KEY ("id")
);
-- ----------------------------
-- Indexes structure for table alarm_event
-- ----------------------------
CREATE INDEX IF NOT EXISTS "idx_astatus_etime"
ON "alarm_event" (
"alarm_status" ASC,
"event_time" ASC
);
CREATE UNIQUE INDEX IF NOT EXISTS "uk_ti_aid"
ON "alarm_event" (
"ne_type" ASC,
"ne_id" ASC,
"alarm_id" ASC
);
-- ----------------------------
-- Records of alarm_event
-- ----------------------------
INSERT INTO "alarm_event" ("id", "ne_type", "ne_id", "alarm_seq", "alarm_id", "alarm_title", "alarm_code", "event_time", "object_uid", "object_name", "object_type", "location_info", "alarm_status", "specific_problem", "specific_problem_id", "add_info", "clear_type", "clear_time", "clear_user", "timestamp") SELECT "id", "ne_type", "ne_id", "alarm_seq", "alarm_id", "alarm_title", "alarm_code", "event_time", "object_uid", "object_name", "object_type", "location_info", "alarm_status", "specific_problem", "specific_problem_id", "add_info", "clear_type", "clear_time", "clear_user", "timestamp" FROM "alarm_event_old";
DROP TABLE IF EXISTS "alarm_event_old";