lamassu-server/migrations/018-alter_devices.js
Fabio Cigliano 12c834469c Migration sql changes (#199)
* safe migration script changes

* lamassu migration script fixes
2018-11-01 13:26:48 +02:00

24 lines
661 B
JavaScript

var db = require('./db')
exports.up = function (next) {
var sql = [
'drop table if exists devices',
'drop table if exists paired_devices',
`create table if not exists devices (
device_id text PRIMARY KEY,
name text NOT NULL,
cashbox integer NOT NULL default 0,
cassette1 integer NOT NULL default 0,
cassette2 integer NOT NULL default 0,
paired boolean NOT NULL default TRUE,
display boolean NOT NULL default TRUE,
created timestamptz NOT NULL default now()
)`,
db.addColumn('pairing_tokens', 'name', 'text NOT NULL')
]
db.multi(sql, next)
}
exports.down = function (next) {
next()
}