PKGBUILD/pkg/repository/db/postgres/ddl/3_table_humidites.up.sql
markus 366dccde12
fix: use go-migrate pkg to init or update db schema
Instead to implement own logic how the database scheme should be updated
or migrated to a newer or older version flucky use now instead the
go-migrate package.
2021-01-30 15:44:21 +01:00

10 lines
709 B
SQL

CREATE TABLE humidities (
id CHAR(36) NOT NULL,
value NUMERIC(10,3) NOT NULL,
date TIMESTAMP WITH TIME ZONE NOT NULL,
sensor_id CHAR(36) NOT NULL,
creation_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
update_date TIMESTAMP WITH TIME ZONE,
CONSTRAINT pk_humidites PRIMARY KEY (id),
CONSTRAINT pk_humidites_sensor_id FOREIGN KEY(sensor_id) REFERENCES sensors(sensor_id) ON DELETE CASCADE ON UPDATE CASCADE
);