Save migrations file on db (#215)
* Revert "Migration sql changes (#199)"
This reverts commit 12c834469c.
* Save migrate file on db
* Add message on migration error in lamassu-update
This commit is contained in:
parent
9af204e609
commit
06f8c57608
58 changed files with 1516 additions and 567 deletions
|
|
@ -2,24 +2,24 @@ var db = require('./db')
|
|||
|
||||
exports.up = function (next) {
|
||||
var sql = [
|
||||
`create table if not exists machine_pings (
|
||||
id uuid PRIMARY KEY,
|
||||
device_id text not null,
|
||||
serial_number integer not null,
|
||||
device_time timestamptz not null,
|
||||
created timestamptz not null default now())`,
|
||||
`create table if not exists aggregated_machine_pings (
|
||||
id uuid PRIMARY KEY,
|
||||
device_id text not null,
|
||||
dropped_pings integer not null,
|
||||
total_pings integer not null,
|
||||
lag_sd_ms integer not null,
|
||||
lag_min_ms integer not null,
|
||||
lag_max_ms integer not null,
|
||||
lag_median_ms integer not null,
|
||||
day date not null)`,
|
||||
db.dropColumn('machine_events', 'device_time'),
|
||||
db.addColumn('machine_events', 'device_time', 'timestamptz')
|
||||
`create table machine_pings (
|
||||
id uuid PRIMARY KEY,
|
||||
device_id text not null,
|
||||
serial_number integer not null,
|
||||
device_time timestamptz not null,
|
||||
created timestamptz not null default now())`,
|
||||
`create table aggregated_machine_pings (
|
||||
id uuid PRIMARY KEY,
|
||||
device_id text not null,
|
||||
dropped_pings integer not null,
|
||||
total_pings integer not null,
|
||||
lag_sd_ms integer not null,
|
||||
lag_min_ms integer not null,
|
||||
lag_max_ms integer not null,
|
||||
lag_median_ms integer not null,
|
||||
day date not null)`,
|
||||
'alter table machine_events drop column device_time',
|
||||
'alter table machine_events add column device_time timestamptz'
|
||||
]
|
||||
db.multi(sql, next)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue