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

33 lines
830 B
TypeScript

import { BaseSchema } from '@adonisjs/lucid/schema'
/**
* Every action done from the dashboard, with the output of the commands.
*/
export default class extends BaseSchema {
protected tableName = 'audit_logs'
async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.string('username').nullable()
table.string('ip').nullable()
table.string('action').notNullable()
table.string('target').nullable()
/**
* "running", "success" or "error"
*/
table.string('status').notNullable()
table.text('output').nullable()
table.timestamp('created_at').notNullable()
table.timestamp('finished_at').nullable()
table.index(['created_at'])
})
}
async down() {
this.schema.dropTable(this.tableName)
}
}