refac: use embed instead of go-bindata, secure closing of transactions
This commit is contained in:
1
pkg/repository/sqlite3/ddl/1_table_devices.down.sql
Normal file
1
pkg/repository/sqlite3/ddl/1_table_devices.down.sql
Normal file
@ -0,0 +1 @@
|
||||
DROP TABLE devices;
|
8
pkg/repository/sqlite3/ddl/1_table_devices.up.sql
Normal file
8
pkg/repository/sqlite3/ddl/1_table_devices.up.sql
Normal file
@ -0,0 +1,8 @@
|
||||
CREATE TABLE devices (
|
||||
device_id CHAR(36) NOT NULL,
|
||||
device_name VARCHAR(64) NOT NULL,
|
||||
device_location VARCHAR(64),
|
||||
creation_date TIMESTAMP DEFAULT (datetime('now', 'localtime')) NOT NULL,
|
||||
update_date TIMESTAMP,
|
||||
CONSTRAINT pk_devices PRIMARY KEY (device_id)
|
||||
);
|
1
pkg/repository/sqlite3/ddl/2_table_sensors.down.sql
Normal file
1
pkg/repository/sqlite3/ddl/2_table_sensors.down.sql
Normal file
@ -0,0 +1 @@
|
||||
DROP TABLE sensors;
|
17
pkg/repository/sqlite3/ddl/2_table_sensors.up.sql
Normal file
17
pkg/repository/sqlite3/ddl/2_table_sensors.up.sql
Normal file
@ -0,0 +1,17 @@
|
||||
CREATE TABLE sensors (
|
||||
sensor_id CHAR(36) NOT NULL,
|
||||
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 INTEGER(1) DEFAULT 1 NOT NULL,
|
||||
tick_duration VARCHAR(6) NOT NULL,
|
||||
device_id CHAR(36) NOT NULL,
|
||||
creation_date TIMESTAMP DEFAULT (datetime('now', 'localtime')) NOT NULL,
|
||||
update_date TIMESTAMP,
|
||||
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
|
||||
);
|
1
pkg/repository/sqlite3/ddl/3_table_humidities.down.sql
Normal file
1
pkg/repository/sqlite3/ddl/3_table_humidities.down.sql
Normal file
@ -0,0 +1 @@
|
||||
DROP TABLE humidities;
|
10
pkg/repository/sqlite3/ddl/3_table_humidities.up.sql
Normal file
10
pkg/repository/sqlite3/ddl/3_table_humidities.up.sql
Normal file
@ -0,0 +1,10 @@
|
||||
CREATE TABLE humidities (
|
||||
id CHAR(36) NOT NULL,
|
||||
value NUMERIC(10,3) NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
sensor_id CHAR(36) NOT NULL,
|
||||
creation_date TIMESTAMP DEFAULT (datetime('now', 'localtime')) NOT NULL,
|
||||
update_date TIMESTAMP,
|
||||
CONSTRAINT pk_humidities PRIMARY KEY(id),
|
||||
CONSTRAINT fk_humidities_sensor_id FOREIGN KEY(sensor_id) REFERENCES sensors(sensor_id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
1
pkg/repository/sqlite3/ddl/4_table_pressures.down.sql
Normal file
1
pkg/repository/sqlite3/ddl/4_table_pressures.down.sql
Normal file
@ -0,0 +1 @@
|
||||
DROP TABLE humidities;
|
10
pkg/repository/sqlite3/ddl/4_table_pressures.up.sql
Normal file
10
pkg/repository/sqlite3/ddl/4_table_pressures.up.sql
Normal file
@ -0,0 +1,10 @@
|
||||
CREATE TABLE pressures (
|
||||
id CHAR(36) NOT NULL,
|
||||
value NUMERIC(10,3) NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
sensor_id CHAR(36) NOT NULL,
|
||||
creation_date TIMESTAMP DEFAULT (datetime('now', 'localtime')) NOT NULL,
|
||||
update_date TIMESTAMP,
|
||||
CONSTRAINT pk_pressures PRIMARY KEY(id),
|
||||
CONSTRAINT fk_pressures_sensor_id FOREIGN KEY(sensor_id) REFERENCES sensors(sensor_id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
1
pkg/repository/sqlite3/ddl/5_table_temperatures.down.sql
Normal file
1
pkg/repository/sqlite3/ddl/5_table_temperatures.down.sql
Normal file
@ -0,0 +1 @@
|
||||
DROP TABLE temperatures;
|
10
pkg/repository/sqlite3/ddl/5_table_temperatures.up.sql
Normal file
10
pkg/repository/sqlite3/ddl/5_table_temperatures.up.sql
Normal file
@ -0,0 +1,10 @@
|
||||
CREATE TABLE temperatures (
|
||||
id CHAR(36) NOT NULL,
|
||||
value NUMERIC(10,3) NOT NULL,
|
||||
date TIMESTAMP NOT NULL,
|
||||
sensor_id CHAR(36) NOT NULL,
|
||||
creation_date TIMESTAMP DEFAULT (datetime('now', 'localtime')) NOT NULL,
|
||||
update_date TIMESTAMP,
|
||||
CONSTRAINT pk_temperatures PRIMARY KEY(id),
|
||||
CONSTRAINT fk_temperatures_id FOREIGN KEY(sensor_id) REFERENCES sensors(sensor_id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
Reference in New Issue
Block a user