fix: postgres columns with timezone
Add timezone for the columns creation_date and update_date, otherwise it's difficult to compare the times correctly in the unit test. Furthermore the default value of the creation_date will now be defined by the postgres implementation of the database interface.
This commit is contained in:
@ -2,6 +2,6 @@ CREATE TABLE IF NOT EXISTS devices (
|
||||
device_id CHAR(36) CONSTRAINT pk_devices PRIMARY KEY,
|
||||
device_name VARCHAR(64) NOT NULL,
|
||||
device_location VARCHAR(64),
|
||||
creation_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_date TIMESTAMP
|
||||
creation_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_date TIMESTAMP WITH TIME ZONE
|
||||
);
|
@ -1,10 +1,10 @@
|
||||
CREATE TABLE IF NOT EXISTS humidities (
|
||||
id CHAR(36) CONSTRAINT pk_humidities PRIMARY KEY,
|
||||
value NUMERIC(10,3) NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
date TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
sensor_id CHAR(36) NOT NULL,
|
||||
creation_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_date TIMESTAMP
|
||||
creation_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_date TIMESTAMP WITH TIME ZONE
|
||||
);
|
||||
|
||||
ALTER TABLE humidities
|
||||
|
@ -1,10 +1,10 @@
|
||||
CREATE TABLE IF NOT EXISTS pressures (
|
||||
id CHAR(36) CONSTRAINT pk_pressures PRIMARY KEY,
|
||||
value NUMERIC(10,3) NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
date TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
sensor_id CHAR(36) NOT NULL,
|
||||
creation_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_date TIMESTAMP
|
||||
creation_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_date TIMESTAMP WITH TIME ZONE
|
||||
);
|
||||
|
||||
ALTER TABLE pressures
|
||||
|
@ -10,8 +10,8 @@ CREATE TABLE IF NOT EXISTS sensors (
|
||||
sensor_enabled BOOLEAN DEFAULT TRUE NOT NULL,
|
||||
tick_duration VARCHAR(6) NOT NULL,
|
||||
device_id CHAR(36) NOT NULL,
|
||||
creation_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_date TIMESTAMP
|
||||
creation_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_date TIMESTAMP WITH TIME ZONE
|
||||
);
|
||||
|
||||
ALTER TABLE sensors
|
||||
|
@ -1,10 +1,10 @@
|
||||
CREATE TABLE IF NOT EXISTS temperatures (
|
||||
id CHAR(36) CONSTRAINT pk_temperatures PRIMARY KEY,
|
||||
value NUMERIC(10,3) NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
date TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
sensor_id CHAR(36) NOT NULL,
|
||||
creation_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_date TIMESTAMP
|
||||
creation_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||
update_date TIMESTAMP WITH TIME ZONE
|
||||
);
|
||||
|
||||
ALTER TABLE temperatures
|
||||
|
@ -15,4 +15,6 @@ SELECT
|
||||
FROM
|
||||
sensors
|
||||
WHERE
|
||||
sensor_id = $1;
|
||||
sensor_id = $1
|
||||
ORDER BY
|
||||
sensor_name ASC;
|
Reference in New Issue
Block a user