Fix indentation and improved comments

This commit is contained in:
Omar Ajoue 2020-12-10 10:00:15 +01:00
parent 416997392e
commit 4c66c18de7
6 changed files with 38 additions and 34 deletions

View file

@ -39,10 +39,10 @@ export class ActiveExecutions {
async add(executionData: IWorkflowExecutionDataProcess, process?: ChildProcess): Promise<string> {
const fullExecutionData: IExecutionDb = {
data: executionData.executionData!, // check if we can use ! here
data: executionData.executionData!, // this is only empty for CLI executions but works fine.
mode: executionData.executionMode,
finished: false,
startedAt: new Date(), // check if this is right
startedAt: new Date(),
workflowData: executionData.workflowData,
};

View file

@ -35,29 +35,29 @@ export let collections: IDatabaseCollections = {
import {
CreateIndexStoppedAt1594828256133,
InitialMigration1587669153312,
WebhookModel1589476000887,
MakeStoppedAtNullable1607431743768,
WebhookModel1589476000887,
} from './databases/postgresdb/migrations';
import {
CreateIndexStoppedAt1594910478695,
InitialMigration1587563438936,
WebhookModel1592679094242,
MakeStoppedAtNullable1607431743766,
WebhookModel1592679094242,
} from './databases/mongodb/migrations';
import {
CreateIndexStoppedAt1594902918301,
InitialMigration1588157391238,
WebhookModel1592447867632,
MakeStoppedAtNullable1607431743767,
WebhookModel1592447867632,
} from './databases/mysqldb/migrations';
import {
CreateIndexStoppedAt1594825041918,
InitialMigration1588102412422,
WebhookModel1592445003908,
MakeStoppedAtNullable1607431743769,
WebhookModel1592445003908,
} from './databases/sqlite/migrations';
import * as path from 'path';

View file

@ -1,13 +1,13 @@
import {MigrationInterface, QueryRunner} from "typeorm";
import * as config from '../../../../config';
export class MakeStoppedAtNullable1607431743766 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
async up(queryRunner: QueryRunner): Promise<void> {
}
public async down(queryRunner: QueryRunner): Promise<void> {
async down(queryRunner: QueryRunner): Promise<void> {
}
}

View file

@ -1,15 +1,15 @@
import {MigrationInterface, QueryRunner} from "typeorm";
import { MigrationInterface, QueryRunner } from "typeorm";
import * as config from '../../../../config';
export class MakeStoppedAtNullable1607431743767 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
async up(queryRunner: QueryRunner): Promise<void> {
const tablePrefix = config.get('database.tablePrefix');
await queryRunner.query('ALTER TABLE `' + tablePrefix + 'execution_entity` MODIFY `stoppedAt` datetime', undefined);
}
public async down(queryRunner: QueryRunner): Promise<void> {
async down(queryRunner: QueryRunner): Promise<void> {
const tablePrefix = config.get('database.tablePrefix');
await queryRunner.query('ALTER TABLE `' + tablePrefix + 'execution_entity` MODIFY `stoppedAt` datetime NOT NULL', undefined);
}

View file

@ -4,12 +4,12 @@ import * as config from '../../../../config';
export class MakeStoppedAtNullable1607431743768 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
async up(queryRunner: QueryRunner): Promise<void> {
const tablePrefix = config.get('database.tablePrefix');
await queryRunner.query('ALTER TABLE `' + tablePrefix + 'execution_entity` ALTER COLUMN `stoppedAt` DROP NOT NULL', undefined);
}
public async down(queryRunner: QueryRunner): Promise<void> {
async down(queryRunner: QueryRunner): Promise<void> {
// Cannot be undone as column might already have null values
}

View file

@ -4,15 +4,19 @@ import * as config from '../../../../config';
export class MakeStoppedAtNullable1607431743769 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
async up(queryRunner: QueryRunner): Promise<void> {
const tablePrefix = config.get('database.tablePrefix');
console.log(`UPDATE SQLITE_MASTER SET SQL = 'CREATE TABLE IF NOT EXISTS "${tablePrefix}execution_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "data" text NOT NULL, "finished" boolean NOT NULL, "mode" varchar NOT NULL, "retryOf" varchar, "retrySuccessId" varchar, "startedAt" datetime NOT NULL, "stoppedAt" datetime, "workflowData" text NOT NULL, "workflowId" varchar)' WHERE NAME = "${tablePrefix}execution_entity";`);
// SQLite does not allow us to simply "alter column"
// We're hacking the way sqlite identifies tables
// Allowing a column to become nullable
// This is a very strict case when this can be done safely
// As no collateral effects exist.
await queryRunner.query(`PRAGMA writable_schema = 1; `, undefined);
await queryRunner.query(`UPDATE SQLITE_MASTER SET SQL = 'CREATE TABLE IF NOT EXISTS "${tablePrefix}execution_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "data" text NOT NULL, "finished" boolean NOT NULL, "mode" varchar NOT NULL, "retryOf" varchar, "retrySuccessId" varchar, "startedAt" datetime NOT NULL, "stoppedAt" datetime, "workflowData" text NOT NULL, "workflowId" varchar)' WHERE NAME = "${tablePrefix}execution_entity";`, undefined);
await queryRunner.query(`PRAGMA writable_schema = 0;`, undefined);
}
public async down(queryRunner: QueryRunner): Promise<void> {
async down(queryRunner: QueryRunner): Promise<void> {
// This cannot be undone as the table might already have nullable values
}