Files
big-brother/api/database/migrations/1770000000001_create_metrics_table.ts
2026-10-12 14:25:22 +02:00

28 lines
773 B
TypeScript

import { BaseSchema } from '@adonisjs/lucid/schema'
/**
* One row per minute with the averaged host metrics.
*/
export default class extends BaseSchema {
protected tableName = 'metrics'
async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.integer('ts').notNullable().index()
table.float('cpu').notNullable()
table.float('load1').nullable()
table.bigInteger('mem_used').notNullable()
table.bigInteger('mem_total').notNullable()
table.bigInteger('disk_used').notNullable()
table.bigInteger('disk_total').notNullable()
table.float('net_rx').nullable()
table.float('net_tx').nullable()
})
}
async down() {
this.schema.dropTable(this.tableName)
}
}