Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/databases/entities/ExecutionEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ExecutionEntity {
@Column({ nullable: true })
retrySuccessId: string;

@Column('varchar', { nullable: true })
@Column('varchar')
status: ExecutionStatus;

@Column(datetimeColumnType)
Expand Down
Original file line number Diff line number Diff line change
@@ -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');
}
}
2 changes: 2 additions & 0 deletions packages/cli/src/databases/migrations/mysqldb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -115,4 +116,5 @@ export const mysqlMigrations: Migration[] = [
MoveSshKeysToDatabase1711390882123,
RemoveNodesAccess1712044305787,
CreateProject1714133768519,
MakeExecutionStatusNonNullable1714133768521,
];
2 changes: 2 additions & 0 deletions packages/cli/src/databases/migrations/postgresdb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -113,4 +114,5 @@ export const postgresMigrations: Migration[] = [
MoveSshKeysToDatabase1711390882123,
RemoveNodesAccess1712044305787,
CreateProject1714133768519,
MakeExecutionStatusNonNullable1714133768521,
];
2 changes: 2 additions & 0 deletions packages/cli/src/databases/migrations/sqlite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -109,6 +110,7 @@ const sqliteMigrations: Migration[] = [
MoveSshKeysToDatabase1711390882123,
RemoveNodesAccess1712044305787,
CreateProject1714133768519,
MakeExecutionStatusNonNullable1714133768521,
];

export { sqliteMigrations };
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/integration/shared/db/executions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
Loading