2021-01-30 14:44:21 +00:00
|
|
|
CREATE TABLE sensors (
|
|
|
|
sensor_id CHAR(36) NOT NULL,
|
2020-06-01 20:36:57 +00:00
|
|
|
sensor_name VARCHAR(64) NOT NULL,
|
|
|
|
sensor_location VARCHAR(64),
|
|
|
|
wire_id VARCHAR(64),
|
|
|
|
i2c_bus VARCHAR(255),
|
|
|
|
i2c_address VARCHAR(12),
|
|
|
|
gpio_number VARCHAR(6),
|
|
|
|
sensor_model VARCHAR(16) NOT NULL,
|
|
|
|
sensor_enabled BOOLEAN DEFAULT TRUE NOT NULL,
|
|
|
|
tick_duration VARCHAR(6) NOT NULL,
|
|
|
|
device_id CHAR(36) NOT NULL,
|
2020-10-07 21:38:27 +00:00
|
|
|
creation_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
2021-01-30 14:44:21 +00:00
|
|
|
update_date TIMESTAMP WITH TIME ZONE,
|
|
|
|
CONSTRAINT pk_sensors PRIMARY KEY(sensor_id),
|
|
|
|
CONSTRAINT fk_sensors_device_id FOREIGN KEY (device_id) REFERENCES devices(device_id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
|
|
);
|