31 lines
1.3 KiB
SQL
31 lines
1.3 KiB
SQL
-- Use TRUNCATE to reset tables and start fresh, which is fine for seed data.
|
|
-- Disable foreign key checks to avoid errors with TRUNCATE order.
|
|
SET FOREIGN_KEY_CHECKS=0;
|
|
TRUNCATE TABLE `sensor_readings`;
|
|
TRUNCATE TABLE `nodes`;
|
|
TRUNCATE TABLE `slots`;
|
|
TRUNCATE TABLE `warehouses`;
|
|
SET FOREIGN_KEY_CHECKS=1;
|
|
|
|
-- Warehouses
|
|
INSERT INTO `warehouses` (`id`, `name`) VALUES (1, 'Main Warehouse'), (2, 'North Annex');
|
|
|
|
-- Slots for Main Warehouse
|
|
INSERT INTO `slots` (`id`, `name`, `warehouse_id`) VALUES (1, 'Slot A-1', 1), (2, 'Slot A-2', 1);
|
|
-- Slots for North Annex
|
|
INSERT INTO `slots` (`id`, `name`, `warehouse_id`) VALUES (3, 'Slot B-1', 2);
|
|
|
|
-- Nodes for Slot A-1
|
|
INSERT INTO `nodes` (`id`, `name`, `slot_id`) VALUES (1, 'Node-001', 1), (2, 'Node-002', 1);
|
|
-- Nodes for Slot A-2
|
|
INSERT INTO `nodes` (`id`, `name`, `slot_id`) VALUES (3, 'Node-003', 2);
|
|
-- Nodes for Slot B-1
|
|
INSERT INTO `nodes` (`id`, `name`, `slot_id`) VALUES (4, 'Node-004', 3);
|
|
|
|
-- Insert a few recent sensor readings for different nodes
|
|
INSERT INTO `sensor_readings` (`node_id`, `temperature`, `humidity`, `co2`, `gas_level`, `pressure`, `light_level`) VALUES
|
|
(1, 22.5, 45.2, 800, 50, 1012.5, 600),
|
|
(2, 25.1, 50.0, 1200, 150, 1010.1, 300),
|
|
(3, 19.8, 40.5, 600, 20, 1015.0, 800),
|
|
(4, 30.0, 65.0, 2500, 300, 1005.0, 100);
|