feat: Create execution model
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
3457ad29d7
commit
82e1f345d4
@@ -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');
|
||||||
|
}
|
33
packages/backend/src/models/execution.ts
Normal file
33
packages/backend/src/models/execution.ts
Normal 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;
|
Reference in New Issue
Block a user