-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `4602066_iot`
--

-- --------------------------------------------------------

--
-- Table structure for table `alarm_equipment`
--

CREATE TABLE `alarm_equipment` (
  `id` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `serial_number` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `equipment_num` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `equipment_type` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `unit` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `alarm_type` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `instructions` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `processing_type` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `time_call` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `processing_time` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `processing_status` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `extension` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `company_id` varchar(255) COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `building_details`
--

CREATE TABLE `building_details` (
  `id` int NOT NULL,
  `company_id` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `building_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `building_type` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `fixed_line` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `mfap_type` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `mfap_brand` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `building_address` varchar(1000) COLLATE utf8mb4_general_ci NOT NULL,
  `latitude` decimal(10,7) DEFAULT NULL,
  `longitude` decimal(10,7) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `building_details`
--

INSERT INTO `building_details` (`id`, `company_id`, `building_name`, `building_type`, `fixed_line`, `mfap_type`, `mfap_brand`, `building_address`, `latitude`, `longitude`) VALUES
(3, '1', 'LTA Services Sdn. Bhd.', 'Residential', '082265761', 'Addressable', 'SEC3002', '2ND FLOOR, LOT 113, PLOT 24, GALA CITY, JALAN TUN JUGAH, 93350, KUCHING, SARAWAK', 1.5118019, 110.3531890);

-- --------------------------------------------------------

--
-- Table structure for table `company_details`
--

CREATE TABLE `company_details` (
  `id` int NOT NULL,
  `company_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `reg_no` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `company_num` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `company_email` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `address` varchar(1000) COLLATE utf8mb4_general_ci NOT NULL,
  `owner_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `owner_num` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `owner_email` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `owner_position` varchar(100) COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `company_details`
--

INSERT INTO `company_details` (`id`, `company_name`, `reg_no`, `company_num`, `company_email`, `address`, `owner_name`, `owner_num`, `owner_email`, `owner_position`) VALUES
(1, 'LTA Services Sdn Bhd', '200501023435', '082265761', 'ltaservicessdnbhd@gmail.com', '2ND FLOOR, LOT 113, PLOT 24, GALA CITY, JALAN TUN JUGAH, 93350, KUCHING, SARAWAK', 'Leo Tan Kia Ou', '0196568936', 'ltaservicessdnbhd@gmail.com', 'Director');

-- --------------------------------------------------------

--
-- Table structure for table `contact_details`
--

CREATE TABLE `contact_details` (
  `id` int NOT NULL,
  `company_id` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `building_name` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `contact_1` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `phone_1` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `email_1` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `position_1` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `contact_2` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `phone_2` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `email_2` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `position_2` varchar(100) COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `contact_details`
--

INSERT INTO `contact_details` (`id`, `company_id`, `building_name`, `contact_1`, `phone_1`, `email_1`, `position_1`, `contact_2`, `phone_2`, `email_2`, `position_2`) VALUES
(3, '1', 'LTA Services Sdn. Bhd.', 'Mohamad Rossafreen Bin Safian', '01110190186', 'ltaserviceit@gmail.com', 'Head of IT', 'VERTI ANAK MEDAN', '0172839731', 'ltaspka1@gmail.com', 'Technician');

-- --------------------------------------------------------

--
-- Table structure for table `faulty_equipment`
--

CREATE TABLE `faulty_equipment` (
  `id` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `serial_number` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `equipment_num` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `equipment_type` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `unit` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `alarm_type` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `instructions` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `processing_type` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `time_call` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `processing_time` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `processing_status` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `extension` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `company_id` varchar(255) COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `gateway`
--

CREATE TABLE `gateway` (
  `gateway_id` int NOT NULL,
  `company_id` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `building_name` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `gateway_location` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `serial_number` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `simcard_number` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `ip_address` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `simcard_operator` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `extension` varchar(255) COLLATE utf8mb4_general_ci NOT NULL,
  `status` enum('good','fault','fire','') COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'good',
  `last_heartbeat` varchar(255) COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `gateway`
--

INSERT INTO `gateway` (`gateway_id`, `company_id`, `building_name`, `gateway_location`, `serial_number`, `simcard_number`, `ip_address`, `simcard_operator`, `extension`, `status`, `last_heartbeat`) VALUES
(3, '1', 'LTA Services Sdn. Bhd.', 'Server Room', '1', '896019220293594768', '183.171.43.217', 'Celcom', 'jpg', 'good', '');

-- --------------------------------------------------------

--
-- Table structure for table `gateway_alerts`
--

CREATE TABLE `gateway_alerts` (
  `id` bigint NOT NULL,
  `gateway_id` varchar(64) NOT NULL,
  `ts_source` varchar(32) NOT NULL,
  `alert_type` enum('fire','fault','normal','alert') NOT NULL,
  `formatted` varchar(255) NOT NULL,
  `data_text` mediumtext,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `gateway_alerts`
--

INSERT INTO `gateway_alerts` (`id`, `gateway_id`, `ts_source`, `alert_type`, `formatted`, `data_text`, `created_at`) VALUES
(1, '1', '2025-11-03 02:26:58', 'normal', 'Gateway 1 BACK ONLINE – signal restored', 'GATEWAY_ONLINE', '2025-11-03 02:26:59'),
(2, '1', '2025-11-03 02:28:51', 'normal', 'Gateway 1 BACK ONLINE – signal restored', 'GATEWAY_ONLINE', '2025-11-03 02:28:51'),
(3, '1', '2025-11-03 02:29:27', 'normal', 'Gateway 1 BACK ONLINE – signal restored', 'GATEWAY_ONLINE', '2025-11-03 02:29:27'),
(4, '1', '2025-11-03 05:30:33', 'fault', 'Gateway 1 OFFLINE – No signal for 3684 s (threshold 2700 s)', 'GATEWAY_OFFLINE', '2025-11-03 05:30:33'),
(5, '1', '2025-11-03 06:22:46', 'normal', 'Gateway 1 BACK ONLINE – signal restored', 'GATEWAY_ONLINE', '2025-11-03 06:22:46');

-- --------------------------------------------------------

--
-- Table structure for table `gateway_events`
--

CREATE TABLE `gateway_events` (
  `id` bigint NOT NULL,
  `gateway_id` varchar(64) NOT NULL,
  `ts_source` varchar(32) NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `type` enum('event','heartbeat','health') NOT NULL,
  `reason` varchar(32) DEFAULT NULL,
  `event` varchar(16) DEFAULT NULL,
  `raw_event` varchar(64) DEFAULT NULL,
  `rssi_dbm` double DEFAULT NULL,
  `bytes_sent` bigint DEFAULT NULL,
  `data_text` mediumtext
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `gateway_events`
--

INSERT INTO `gateway_events` (`id`, `gateway_id`, `ts_source`, `created_at`, `type`, `reason`, `event`, `raw_event`, `rssi_dbm`, `bytes_sent`, `data_text`) VALUES
(1, '1', '2025-11-03 10:26:54', '2025-11-03 02:26:59', 'event', 'event_change', 'NORMAL', 'NORMAL', -80, 415, 'Normal'),
(2, '1', '2025-11-03 10:57:42', '2025-11-03 02:57:46', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -86, 412, 'Normal'),
(3, '1', '2025-11-03 11:28:07', '2025-11-03 03:28:08', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -76, 413, 'Normal'),
(4, '1', '2025-11-03 11:58:15', '2025-11-03 03:58:15', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -82, 412, 'Normal'),
(5, '1', '2025-11-03 12:29:08', '2025-11-03 04:29:09', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -76, 413, 'Normal'),
(6, '1', '2025-11-03 14:22:45', '2025-11-03 06:22:46', 'event', 'event_change', 'NORMAL', 'NORMAL', NULL, 347, 'Normal'),
(7, '1', '2025-11-03 14:52:45', '2025-11-03 06:52:46', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -77, 412, 'Normal'),
(8, '1', '2025-11-03 15:22:48', '2025-11-03 07:22:51', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -80, 413, 'Normal'),
(9, '1', '2025-11-03 15:52:57', '2025-11-03 07:53:04', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -75, 412, 'Normal'),
(10, '1', '2025-11-03 16:22:59', '2025-11-03 08:23:04', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -75, 412, 'Normal'),
(11, '1', '2025-11-03 16:53:41', '2025-11-03 08:53:42', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -76, 413, 'Normal'),
(12, '1', '2025-11-03 17:23:47', '2025-11-03 09:23:48', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -75, 412, 'Normal'),
(13, '1', '2025-11-03 17:53:52', '2025-11-03 09:53:53', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -86, 412, 'Normal'),
(14, '1', '2025-11-03 18:23:55', '2025-11-03 10:23:56', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 412, 'Normal'),
(15, '1', '2025-11-03 18:54:12', '2025-11-03 10:54:14', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -75, 412, 'Normal'),
(16, '1', '2025-11-03 19:24:24', '2025-11-03 11:24:25', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -76, 413, 'Normal'),
(17, '1', '2025-11-03 19:54:42', '2025-11-03 11:54:42', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -76, 412, 'Normal'),
(18, '1', '2025-11-03 20:24:44', '2025-11-03 12:24:45', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 413, 'Normal'),
(19, '1', '2025-11-03 20:54:52', '2025-11-03 12:54:52', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -81, 412, 'Normal'),
(20, '1', '2025-11-03 21:24:56', '2025-11-03 13:24:57', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -81, 412, 'Normal'),
(21, '1', '2025-11-03 21:55:06', '2025-11-03 13:55:06', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 412, 'Normal'),
(22, '1', '2025-11-03 22:25:16', '2025-11-03 14:25:17', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 412, 'Normal'),
(23, '1', '2025-11-03 22:55:33', '2025-11-03 14:55:34', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -76, 412, 'Normal'),
(24, '1', '2025-11-03 23:25:43', '2025-11-03 15:25:44', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -76, 413, 'Normal'),
(25, '1', '2025-11-03 23:55:49', '2025-11-03 15:55:50', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -76, 412, 'Normal'),
(26, '1', '2025-11-04 00:26:28', '2025-11-03 16:26:29', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -76, 413, 'Normal'),
(27, '1', '2025-11-04 00:56:38', '2025-11-03 16:56:40', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -78, 412, 'Normal'),
(28, '1', '2025-11-04 01:26:57', '2025-11-03 17:26:58', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 412, 'Normal'),
(29, '1', '2025-11-04 01:56:59', '2025-11-03 17:57:01', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 413, 'Normal'),
(30, '1', '2025-11-04 02:27:01', '2025-11-03 18:27:03', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 412, 'Normal'),
(31, '1', '2025-11-04 02:57:13', '2025-11-03 18:57:14', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 412, 'Normal'),
(32, '1', '2025-11-04 03:27:19', '2025-11-03 19:27:19', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 412, 'Normal'),
(33, '1', '2025-11-04 03:57:24', '2025-11-03 19:57:25', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 412, 'Normal'),
(34, '1', '2025-11-04 04:27:25', '2025-11-03 20:27:25', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -79, 411, 'Normal'),
(35, '1', '2025-11-04 04:57:32', '2025-11-03 20:57:33', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -80, 412, 'Normal'),
(36, '1', '2025-11-04 05:27:33', '2025-11-03 21:27:33', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -81, 412, 'Normal'),
(37, '1', '2025-11-04 05:57:43', '2025-11-03 21:57:44', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -75, 412, 'Normal'),
(38, '1', '2025-11-04 06:27:47', '2025-11-03 22:27:47', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -75, 412, 'Normal'),
(39, '1', '2025-11-04 06:57:58', '2025-11-03 22:57:59', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -75, 413, 'Normal'),
(40, '1', '2025-11-04 07:28:06', '2025-11-03 23:28:06', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -75, 412, 'Normal'),
(41, '1', '2025-11-04 07:58:12', '2025-11-03 23:58:13', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -78, 412, 'Normal'),
(42, '1', '2025-11-04 08:28:18', '2025-11-04 00:28:19', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -75, 412, 'Normal'),
(43, '1', '2025-11-04 08:58:19', '2025-11-04 00:58:19', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -78, 412, 'Normal'),
(44, '1', '2025-11-04 09:28:23', '2025-11-04 01:28:25', 'heartbeat', 'heartbeat', 'NORMAL', 'NORMAL', -70, 412, 'Normal');

-- --------------------------------------------------------

--
-- Table structure for table `gateway_status`
--

CREATE TABLE `gateway_status` (
  `gateway_id` varchar(64) NOT NULL,
  `status` enum('online','offline','unknown') NOT NULL DEFAULT 'unknown',
  `last_seen_epoch` bigint DEFAULT NULL,
  `last_seen_iso` varchar(32) DEFAULT NULL,
  `last_health_iso` varchar(32) DEFAULT NULL,
  `last_event_iso` varchar(32) DEFAULT NULL,
  `offline_alert_sent` tinyint(1) NOT NULL DEFAULT '0',
  `online_alert_sent` tinyint(1) NOT NULL DEFAULT '0',
  `notes` varchar(255) DEFAULT NULL,
  `panel_status` varchar(16) DEFAULT NULL,
  `serial_idle_s` int DEFAULT NULL,
  `rssi_dbm` double DEFAULT NULL,
  `current_event` varchar(16) DEFAULT NULL,
  `last_raw_event` varchar(64) DEFAULT NULL,
  `last_reason` varchar(32) DEFAULT NULL,
  `last_data` mediumtext,
  `bytes_sent` bigint DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `gateway_status`
--

INSERT INTO `gateway_status` (`gateway_id`, `status`, `last_seen_epoch`, `last_seen_iso`, `last_health_iso`, `last_event_iso`, `offline_alert_sent`, `online_alert_sent`, `notes`, `panel_status`, `serial_idle_s`, `rssi_dbm`, `current_event`, `last_raw_event`, `last_reason`, `last_data`, `bytes_sent`, `updated_at`) VALUES
('1', 'online', 1762219705, '2025-11-04T01:28:25Z', NULL, '2025-11-04T09:28:23Z', 0, 1, 'Signal received', NULL, NULL, -70, 'NORMAL', 'NORMAL', 'heartbeat', 'Normal', 412, '2025-11-04 01:28:25');

-- --------------------------------------------------------

--
-- Table structure for table `image`
--

CREATE TABLE `image` (
  `id` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `companyname` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `date` varchar(100) COLLATE utf8mb4_general_ci NOT NULL,
  `extension` varchar(10) COLLATE utf8mb4_general_ci NOT NULL,
  `company_id` varchar(255) COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `usage_daily`
--

CREATE TABLE `usage_daily` (
  `gateway_id` varchar(64) NOT NULL,
  `ymd` date NOT NULL,
  `up_bytes` bigint NOT NULL DEFAULT '0',
  `down_bytes` bigint NOT NULL DEFAULT '0',
  `requests` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `usage_daily`
--

INSERT INTO `usage_daily` (`gateway_id`, `ymd`, `up_bytes`, `down_bytes`, `requests`) VALUES
('1', '2025-11-03', 0, 0, 41),
('1', '2025-11-04', 0, 0, 3);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `alarm_equipment`
--
ALTER TABLE `alarm_equipment`
  ADD PRIMARY KEY (`serial_number`);

--
-- Indexes for table `building_details`
--
ALTER TABLE `building_details`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `company_details`
--
ALTER TABLE `company_details`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `contact_details`
--
ALTER TABLE `contact_details`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `faulty_equipment`
--
ALTER TABLE `faulty_equipment`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `gateway`
--
ALTER TABLE `gateway`
  ADD PRIMARY KEY (`gateway_id`);

--
-- Indexes for table `gateway_alerts`
--
ALTER TABLE `gateway_alerts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_ga_gateway` (`gateway_id`),
  ADD KEY `idx_ga_created` (`created_at`);

--
-- Indexes for table `gateway_events`
--
ALTER TABLE `gateway_events`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_ge_gateway` (`gateway_id`),
  ADD KEY `idx_ge_created` (`created_at`);

--
-- Indexes for table `gateway_status`
--
ALTER TABLE `gateway_status`
  ADD PRIMARY KEY (`gateway_id`);

--
-- Indexes for table `image`
--
ALTER TABLE `image`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `usage_daily`
--
ALTER TABLE `usage_daily`
  ADD PRIMARY KEY (`gateway_id`,`ymd`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `building_details`
--
ALTER TABLE `building_details`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `company_details`
--
ALTER TABLE `company_details`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `contact_details`
--
ALTER TABLE `contact_details`
  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `gateway`
--
ALTER TABLE `gateway`
  MODIFY `gateway_id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `gateway_alerts`
--
ALTER TABLE `gateway_alerts`
  MODIFY `id` bigint NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `gateway_events`
--
ALTER TABLE `gateway_events`
  MODIFY `id` bigint NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=45;
COMMIT;

