mirror of
https://github.com/morten-olsen/mini-loader.git
synced 2026-02-08 01:36:26 +01:00
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { Knex } from 'knex';
|
|
|
|
const name = 'init';
|
|
|
|
const up = async (knex: Knex) => {
|
|
await knex.schema.createTable('loads', (table) => {
|
|
table.string('id').primary();
|
|
table.string('name').nullable();
|
|
table.string('script').notNullable();
|
|
});
|
|
|
|
await knex.schema.createTable('runs', (table) => {
|
|
table.string('id').primary();
|
|
table.string('loadId').notNullable();
|
|
table.string('status').notNullable();
|
|
table.string('script').notNullable();
|
|
table.string('input').nullable();
|
|
table.string('error').nullable();
|
|
table.timestamp('startedAt').nullable();
|
|
table.timestamp('endedAt').nullable();
|
|
|
|
table.index('loadId');
|
|
table.index('status');
|
|
});
|
|
|
|
await knex.schema.createTable('logs', (table) => {
|
|
table.string('id').primary();
|
|
table.string('runId').notNullable();
|
|
table.string('loadId').notNullable();
|
|
table.string('severity').notNullable();
|
|
table.string('message').notNullable();
|
|
table.jsonb('data').nullable();
|
|
table.timestamp('timestamp').notNullable();
|
|
|
|
table.index('runId');
|
|
});
|
|
|
|
await knex.schema.createTable('artifacts', (table) => {
|
|
table.string('id').primary();
|
|
table.string('name').notNullable();
|
|
table.string('runId').notNullable();
|
|
table.string('loadId').notNullable();
|
|
table.text('data').notNullable();
|
|
|
|
table.index('runId');
|
|
});
|
|
};
|
|
|
|
const down = async (knex: Knex) => {
|
|
await knex.schema.dropTable('loads');
|
|
await knex.schema.dropTable('runs');
|
|
await knex.schema.dropTable('logs');
|
|
await knex.schema.dropTable('artifacts');
|
|
};
|
|
|
|
export { name, up, down };
|