diff --git a/process.go b/process.go index 3b10f33..6b3ad37 100644 --- a/process.go +++ b/process.go @@ -88,19 +88,19 @@ const ( // SQL Query to store current data UpsertCurrentQuery string = ` INSERT INTO current VALUES ($1, $2, $3) - ON CONFLICT (time, phase) DO UPDATE + ON CONFLICT (timestamp, phase) DO UPDATE SET current = excluded.current` // SQL Query to store power data UpsertPowerQuery string = ` INSERT INTO power VALUES ($1, $2) - ON CONFLICT (time) DO UPDATE + ON CONFLICT (timestamp) DO UPDATE SET power = excluded.power` // SQL Query to store energy data UpsertEnergyQuery string = ` INSERT INTO energy VALUES ($1, $2, $3) - ON CONFLICT (time, tariff) DO UPDATE + ON CONFLICT (timestamp, tariff) DO UPDATE SET reading = excluded.reading` ) diff --git a/schemas/002_rename.sql b/schemas/002_rename.sql new file mode 100644 index 0000000..8f29007 --- /dev/null +++ b/schemas/002_rename.sql @@ -0,0 +1,9 @@ +-- +goose Up +ALTER TABLE current RENAME COLUMN time TO timestamp; +ALTER TABLE power RENAME COLUMN time TO timestamp; +ALTER TABLE energy RENAME COLUMN time TO timestamp; + +-- +goose Down +ALTER TABLE current RENAME COLUMN timestamp TO time; +ALTER TABLE power RENAME COLUMN timestamp TO time; +ALTER TABLE energy RENAME COLUMN timestamp TO time;