-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Reactivate workflow locking (#4770)
* feat: Reenable workflow locking Co-authored-by: freyamade <[email protected]> Co-authored-by: Csaba Tuncsik <[email protected]>
- Loading branch information
1 parent
915f144
commit 4813da5
Showing
19 changed files
with
249 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
packages/cli/src/databases/migrations/mysqldb/1669739707125-AddWorkflowVersionIdColumn.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import { logMigrationEnd, logMigrationStart } from '@db/utils/migrationHelpers'; | ||
import config from '@/config'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
export class AddWorkflowVersionIdColumn1669739707125 implements MigrationInterface { | ||
name = 'AddWorkflowVersionIdColumn1669739707125'; | ||
|
||
async up(queryRunner: QueryRunner): Promise<void> { | ||
logMigrationStart(this.name); | ||
|
||
const tablePrefix = config.getEnv('database.tablePrefix'); | ||
|
||
await queryRunner.query( | ||
`ALTER TABLE ${tablePrefix}workflow_entity ADD COLUMN versionId CHAR(36)`, | ||
); | ||
|
||
const workflowIds: Array<{ id: number }> = await queryRunner.query(` | ||
SELECT id | ||
FROM ${tablePrefix}workflow_entity | ||
`); | ||
|
||
workflowIds.map(({ id }) => { | ||
const [updateQuery, updateParams] = queryRunner.connection.driver.escapeQueryWithParameters( | ||
` | ||
UPDATE ${tablePrefix}workflow_entity | ||
SET versionId = :versionId | ||
WHERE id = '${id}' | ||
`, | ||
{ versionId: uuidv4() }, | ||
{}, | ||
); | ||
|
||
return queryRunner.query(updateQuery, updateParams); | ||
}); | ||
|
||
logMigrationEnd(this.name); | ||
} | ||
|
||
async down(queryRunner: QueryRunner) { | ||
const tablePrefix = config.getEnv('database.tablePrefix'); | ||
|
||
await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_entity DROP COLUMN versionId`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/cli/src/databases/migrations/postgresdb/1669739707126-AddWorkflowVersionIdColumn.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import { getTablePrefix, logMigrationEnd, logMigrationStart } from '@db/utils/migrationHelpers'; | ||
import config from '@/config'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
export class AddWorkflowVersionIdColumn1669739707126 implements MigrationInterface { | ||
name = 'AddWorkflowVersionIdColumn1669739707126'; | ||
|
||
async up(queryRunner: QueryRunner) { | ||
logMigrationStart(this.name); | ||
|
||
const tablePrefix = getTablePrefix(); | ||
await queryRunner.query( | ||
`ALTER TABLE ${tablePrefix}workflow_entity ADD COLUMN "versionId" CHAR(36)`, | ||
); | ||
|
||
const workflowIds: Array<{ id: number }> = await queryRunner.query(` | ||
SELECT id | ||
FROM ${tablePrefix}workflow_entity | ||
`); | ||
|
||
workflowIds.map(({ id }) => { | ||
const [updateQuery, updateParams] = queryRunner.connection.driver.escapeQueryWithParameters( | ||
` | ||
UPDATE ${tablePrefix}workflow_entity | ||
SET "versionId" = :versionId | ||
WHERE id = '${id}' | ||
`, | ||
{ versionId: uuidv4() }, | ||
{}, | ||
); | ||
|
||
return queryRunner.query(updateQuery, updateParams); | ||
}); | ||
|
||
logMigrationEnd(this.name); | ||
} | ||
|
||
async down(queryRunner: QueryRunner) { | ||
const tablePrefix = config.getEnv('database.tablePrefix'); | ||
|
||
await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_entity DROP COLUMN "versionId"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/cli/src/databases/migrations/sqlite/1669739707124-AddWorkflowVersionIdColumn.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import { logMigrationEnd, logMigrationStart } from '@db/utils/migrationHelpers'; | ||
import config from '@/config'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
export class AddWorkflowVersionIdColumn1669739707124 implements MigrationInterface { | ||
name = 'AddWorkflowVersionIdColumn1669739707124'; | ||
|
||
async up(queryRunner: QueryRunner) { | ||
logMigrationStart(this.name); | ||
|
||
const tablePrefix = config.getEnv('database.tablePrefix'); | ||
|
||
await queryRunner.query( | ||
`ALTER TABLE \`${tablePrefix}workflow_entity\` ADD COLUMN "versionId" char(36)`, | ||
); | ||
|
||
const workflowIds: Array<{ id: number }> = await queryRunner.query(` | ||
SELECT id | ||
FROM "${tablePrefix}workflow_entity" | ||
`); | ||
|
||
workflowIds.map(({ id }) => { | ||
const [updateQuery, updateParams] = queryRunner.connection.driver.escapeQueryWithParameters( | ||
` | ||
UPDATE "${tablePrefix}workflow_entity" | ||
SET versionId = :versionId | ||
WHERE id = '${id}' | ||
`, | ||
{ versionId: uuidv4() }, | ||
{}, | ||
); | ||
|
||
return queryRunner.query(updateQuery, updateParams); | ||
}); | ||
|
||
logMigrationEnd(this.name); | ||
} | ||
|
||
async down(queryRunner: QueryRunner) { | ||
const tablePrefix = config.getEnv('database.tablePrefix'); | ||
|
||
await queryRunner.query( | ||
`ALTER TABLE \`${tablePrefix}workflow_entity\` DROP COLUMN "versionId"`, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.