Optimize machine pings query (#222)
* refactor recordPing method * optimize queries * migrate machine_pings remove id, serial_number add primary key on device_id add unique constraint on device_id * remove filelds from query, rename migration, delete duplicate migration * truncate machine_pings in migration
This commit is contained in:
parent
e7bb29341d
commit
13040f41a1
3 changed files with 22 additions and 12 deletions
17
migrations/1542638179228-alter-machine-pings.js
Normal file
17
migrations/1542638179228-alter-machine-pings.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
const db = require('./db')
|
||||
|
||||
exports.up = function(next) {
|
||||
var sql = [
|
||||
'TRUNCATE TABLE machine_pings',
|
||||
'ALTER TABLE machine_pings DROP id',
|
||||
'ALTER TABLE machine_pings DROP serial_number',
|
||||
'ALTER TABLE machine_pings ADD CONSTRAINT PK_device_id PRIMARY KEY (device_id)',
|
||||
'ALTER TABLE machine_pings ADD CONSTRAINT U_device_id UNIQUE(device_id)'
|
||||
]
|
||||
|
||||
db.multi(sql, next)
|
||||
};
|
||||
|
||||
exports.down = function(next) {
|
||||
next();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue