mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
misc: updated statement timeout
This commit is contained in:
@@ -2,14 +2,24 @@ import { Knex } from "knex";
|
|||||||
|
|
||||||
import { TableName } from "../schemas";
|
import { TableName } from "../schemas";
|
||||||
|
|
||||||
|
const MIGRATION_TIMEOUT = 30 * 60 * 1000; // 30 minutes
|
||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
|
const result = await knex.raw("SHOW statement_timeout");
|
||||||
|
const originalTimeout = result.rows[0].statement_timeout;
|
||||||
|
|
||||||
await knex.transaction(async (tx) => {
|
await knex.transaction(async (tx) => {
|
||||||
const hasIdentityOrgCol = await tx.schema.hasColumn(TableName.Identity, "orgId");
|
try {
|
||||||
if (hasIdentityOrgCol) {
|
await tx.raw(`SET statement_timeout = ${MIGRATION_TIMEOUT}`);
|
||||||
await tx(TableName.Identity).whereNull("orgId").delete();
|
const hasIdentityOrgCol = await tx.schema.hasColumn(TableName.Identity, "orgId");
|
||||||
await tx.schema.alterTable(TableName.Identity, (t) => {
|
if (hasIdentityOrgCol) {
|
||||||
t.uuid("orgId").notNullable().alter();
|
await tx(TableName.Identity).whereNull("orgId").delete();
|
||||||
});
|
await tx.schema.alterTable(TableName.Identity, (t) => {
|
||||||
|
t.uuid("orgId").notNullable().alter();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
await knex.raw(`SET statement_timeout = '${originalTimeout}'`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user