feat: Create execution model

This commit is contained in:
Faruk AYDIN
2022-02-19 12:38:15 +03:00
committed by Ömer Faruk Aydın
parent 3457ad29d7
commit 82e1f345d4
2 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import { Knex } from 'knex';
export async function up(knex: Knex): Promise<void> {
return knex.schema.createTable('executions', (table) => {
table.increments('id');
table.integer('flow_id').references('id').inTable('flows');
table.boolean('test_run').notNullable().defaultTo(false);
table.timestamps(true, true);
});
}
export async function down(knex: Knex): Promise<void> {
return knex.schema.dropTable('executions');
}

View File

@@ -0,0 +1,33 @@
import Base from './base';
import Flow from './flow';
class Execution extends Base {
id!: string;
flowId!: number;
testRun: boolean;
static tableName = 'executions';
static jsonSchema = {
type: 'object',
properties: {
id: { type: 'string' },
flowId: { type: 'integer' },
testRun: { type: 'boolean' },
},
};
static relationMappings = () => ({
flow: {
relation: Base.BelongsToOneRelation,
modelClass: Flow,
join: {
from: 'executions.flow_id',
to: 'flows.id',
},
},
});
}
export default Execution;