fix: add postgres backend

changes:
- Add postgres backend
- Modified or added table attributes.
  UpdateDate, ForeignKeys, Booleans
- Fix test for sqlite and postgres. Compare json instead the struct.
This commit is contained in:
2020-06-01 22:36:57 +02:00
parent a1c28a0a2e
commit 4931c63c10
46 changed files with 822 additions and 245 deletions

View File

@ -4,8 +4,9 @@ import "time"
// Device represent a device with all his settings.
type Device struct {
ID string `json:"id" xml:"id"`
Name string `json:"name" xml:"name"`
Location *string `json:"location" xml:"location"`
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
ID string `json:"id" xml:"id"`
Name string `json:"name" xml:"name"`
Location *string `json:"location" xml:"location"`
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
UpdateDate *time.Time `json:"update_date" xml:"update_date"`
}

View File

@ -13,6 +13,6 @@ type MeasuredValue struct {
ValueType string `json:"value_type" xml:"value_type"`
Date time.Time `json:"date" xml:"date"`
SensorID string `json:"sensor_id" xml:"sensor_id"`
CreationDate *time.Time `json:"creation_date" xml:"creation_date"`
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
UpdateDate *time.Time `json:"update_date" xml:"update_date"`
}

View File

@ -7,18 +7,19 @@ import (
// Sensor represents a sensor with all his settings. The struct does not
// contains any read method.
type Sensor struct {
ID string `json:"id" xml:"id"`
Name string `json:"name" xml:"name"`
Location string `json:"location" xml:"location"`
WireID *string `json:"wire_id" xml:"wire_id"`
I2CBus *int `json:"i2c_bus" xml:"i2c_bus"`
I2CAddress *uint8 `json:"i2c_address" xml:"i2c_address"`
GPIONumber string `json:"gpio_number" xml:"gpio_number"`
Model string `json:"model" xml:"model"`
Enabled bool `json:"enabled" xml:"enabled"`
TickDuration string `json:"tick_duration" xml:"tick_duration"`
DeviceID string `json:"device_id" xml:"device_id"`
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
ID string `json:"id" xml:"id"`
Name string `json:"name" xml:"name"`
Location string `json:"location" xml:"location"`
WireID *string `json:"wire_id" xml:"wire_id"`
I2CBus *int `json:"i2c_bus" xml:"i2c_bus"`
I2CAddress *uint8 `json:"i2c_address" xml:"i2c_address"`
GPIONumber string `json:"gpio_number" xml:"gpio_number"`
Model string `json:"model" xml:"model"`
Enabled bool `json:"enabled" xml:"enabled"`
TickDuration string `json:"tick_duration" xml:"tick_duration"`
DeviceID string `json:"device_id" xml:"device_id"`
CreationDate time.Time `json:"creation_date" xml:"creation_date"`
UpdateDate *time.Time `json:"update_date" xml:"update_date"`
}
// GetID returns the UUID of the sensor.