first commit

This commit is contained in:
Rutra committed 2026-10-12 14:25:22 +02:00
commit 3c0479faf0
169 files changed
+27617

No files matched your search

@@ -0,0 +1,30 @@
import { BaseSchema } from '@adonisjs/lucid/schema'
export default class extends BaseSchema {
protected tableName = 'users'
async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id').notNullable()
table.string('username', 64).notNullable().unique()
table.string('password').notNullable()
/**
* TOTP secret, encrypted with the APP_KEY.
*/
table.text('totp_secret').notNullable()
/**
* Last accepted TOTP time step, to refuse a code being replayed.
*/
table.integer('totp_last_step').nullable()
table.timestamp('created_at').notNullable()
table.timestamp('updated_at').nullable()
})
}
async down() {
this.schema.dropTable(this.tableName)
}
}
@@ -0,0 +1,27 @@
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)
}
}
@@ -0,0 +1,57 @@
import { BaseSchema } from '@adonisjs/lucid/schema'
/**
* Sites are synchronized from the Caddyfile and checked every minute.
*/
export default class extends BaseSchema {
async up() {
this.schema.createTable('sites', (table) => {
table.increments('id')
table.string('domain').notNullable().unique()
/**
* False once the domain disappeared from the Caddyfile.
*/
table.boolean('active').notNullable().defaultTo(true)
/**
* What Caddy serves: "proxy" (upstream = container:port) or "static" (upstream = root path).
*/
table.string('kind').nullable()
table.string('upstream').nullable()
table.boolean('last_ok').nullable()
table.integer('last_status').nullable()
table.integer('last_response_ms').nullable()
table.text('last_error').nullable()
table.integer('last_checked_at').nullable()
table.integer('cert_expires_at').nullable()
table.integer('cert_checked_at').nullable()
table.timestamp('created_at').notNullable()
table.timestamp('updated_at').nullable()
})
this.schema.createTable('site_checks', (table) => {
table.increments('id')
table
.integer('site_id')
.notNullable()
.unsigned()
.references('id')
.inTable('sites')
.onDelete('CASCADE')
table.integer('ts').notNullable()
table.boolean('ok').notNullable()
table.integer('status').nullable()
table.integer('response_ms').nullable()
table.text('error').nullable()
table.index(['site_id', 'ts'])
})
}
async down() {
this.schema.dropTable('site_checks')
this.schema.dropTable('sites')
}
}
@@ -0,0 +1,32 @@
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)
}
}
@@ -0,0 +1,22 @@
import { BaseSchema } from '@adonisjs/lucid/schema'
/**
* Previous contents of the Caddyfile, saved before every change.
*/
export default class extends BaseSchema {
protected tableName = 'caddyfile_versions'
async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.text('content').notNullable()
table.string('username').nullable()
table.string('reason').nullable()
table.timestamp('created_at').notNullable()
})
}
async down() {
this.schema.dropTable(this.tableName)
}
}