refactor(core): Make execution status non-nullable (no-changelog) (#9483)

This commit is contained in:
Iván Ovejero 2024-05-22 16:56:05 +02:00 committed by GitHub
parent 1cb6c12b4f
commit bc219e0499
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 32 additions and 2 deletions

View file

@ -40,7 +40,7 @@ export class ExecutionEntity {
@Column({ nullable: true })
retrySuccessId: string;
@Column('varchar', { nullable: true })
@Column('varchar')
status: ExecutionStatus;
@Column(datetimeColumnType)

View file

@ -0,0 +1,22 @@
import type { IrreversibleMigration, MigrationContext } from '@/databases/types';
export class MakeExecutionStatusNonNullable1714133768521 implements IrreversibleMigration {
async up({ escape, runQuery, schemaBuilder }: MigrationContext) {
const executionEntity = escape.tableName('execution_entity');
const status = escape.columnName('status');
const finished = escape.columnName('finished');
const query = `
UPDATE ${executionEntity}
SET ${status} = CASE
WHEN ${finished} = true THEN 'success'
WHEN ${finished} = false THEN 'error'
END
WHERE ${status} IS NULL;
`;
await runQuery(query);
await schemaBuilder.addNotNull('execution_entity', 'status');
}
}

View file

@ -56,6 +56,7 @@ import { DropRoleMapping1705429061930 } from '../common/1705429061930-DropRoleMa
import { RemoveFailedExecutionStatus1711018413374 } from '../common/1711018413374-RemoveFailedExecutionStatus';
import { MoveSshKeysToDatabase1711390882123 } from '../common/1711390882123-MoveSshKeysToDatabase';
import { RemoveNodesAccess1712044305787 } from '../common/1712044305787-RemoveNodesAccess';
import { MakeExecutionStatusNonNullable1714133768521 } from '../common/1714133768521-MakeExecutionStatusNonNullable';
export const mysqlMigrations: Migration[] = [
InitialMigration1588157391238,
@ -115,4 +116,5 @@ export const mysqlMigrations: Migration[] = [
MoveSshKeysToDatabase1711390882123,
RemoveNodesAccess1712044305787,
CreateProject1714133768519,
MakeExecutionStatusNonNullable1714133768521,
];

View file

@ -55,6 +55,7 @@ import { DropRoleMapping1705429061930 } from '../common/1705429061930-DropRoleMa
import { RemoveFailedExecutionStatus1711018413374 } from '../common/1711018413374-RemoveFailedExecutionStatus';
import { MoveSshKeysToDatabase1711390882123 } from '../common/1711390882123-MoveSshKeysToDatabase';
import { RemoveNodesAccess1712044305787 } from '../common/1712044305787-RemoveNodesAccess';
import { MakeExecutionStatusNonNullable1714133768521 } from '../common/1714133768521-MakeExecutionStatusNonNullable';
export const postgresMigrations: Migration[] = [
InitialMigration1587669153312,
@ -113,4 +114,5 @@ export const postgresMigrations: Migration[] = [
MoveSshKeysToDatabase1711390882123,
RemoveNodesAccess1712044305787,
CreateProject1714133768519,
MakeExecutionStatusNonNullable1714133768521,
];

View file

@ -53,6 +53,7 @@ import { DropRoleMapping1705429061930 } from './1705429061930-DropRoleMapping';
import { RemoveFailedExecutionStatus1711018413374 } from '../common/1711018413374-RemoveFailedExecutionStatus';
import { MoveSshKeysToDatabase1711390882123 } from '../common/1711390882123-MoveSshKeysToDatabase';
import { RemoveNodesAccess1712044305787 } from '../common/1712044305787-RemoveNodesAccess';
import { MakeExecutionStatusNonNullable1714133768521 } from '../common/1714133768521-MakeExecutionStatusNonNullable';
const sqliteMigrations: Migration[] = [
InitialMigration1588102412422,
@ -109,6 +110,7 @@ const sqliteMigrations: Migration[] = [
MoveSshKeysToDatabase1711390882123,
RemoveNodesAccess1712044305787,
CreateProject1714133768519,
MakeExecutionStatusNonNullable1714133768521,
];
export { sqliteMigrations };

View file

@ -161,6 +161,7 @@ test('should report credential in not recently executed workflow', async () => {
stoppedAt: date,
workflowId: workflow.id,
waitTill: null,
status: 'success',
});
await Container.get(ExecutionDataRepository).save({
execution: savedExecution,
@ -228,6 +229,7 @@ test('should not report credentials in recently executed workflow', async () =>
stoppedAt: date,
workflowId: workflow.id,
waitTill: null,
status: 'success',
});
await Container.get(ExecutionDataRepository).save({

View file

@ -30,7 +30,7 @@ export async function createExecution(
...(workflow !== undefined && { workflowId: workflow.id }),
stoppedAt: stoppedAt ?? new Date(),
waitTill: waitTill ?? null,
status,
status: status ?? 'success',
deletedAt,
});