lamassu-server/packages/server/migrations/1751291688761-add-machine-groups.js
2025-12-31 19:04:13 +01:00

18 lines
559 B
JavaScript

var db = require('./db')
var { defaultMachineGroup } = require('../lib/constants')
exports.up = function (next) {
const sql = [
`create table machine_groups (
id uuid PRIMARY KEY,
name text UNIQUE NOT NULL
)`,
`insert into machine_groups (id, name) VALUES ('${defaultMachineGroup.uuid}','${defaultMachineGroup.name}')`,
`alter table devices add column machine_group_id uuid references machine_groups (id) DEFAULT '${defaultMachineGroup.uuid}' NOT NULL`,
]
db.runAll(sql, next)
}
exports.down = function (next) {
next()
}