mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 03:27:38 +00:00
feat: added timeout function to migration
This commit is contained in:
@@ -269,7 +269,14 @@ const kickOutSshProject = async (knex: Knex, oldProjectId: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const BATCH_SIZE = 1000;
|
const BATCH_SIZE = 1000;
|
||||||
|
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;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await knex.raw(`SET statement_timeout = ${MIGRATION_TIMEOUT}`);
|
||||||
|
|
||||||
const hasTemplateTypeColumn = await knex.schema.hasColumn(TableName.ProjectTemplates, "type");
|
const hasTemplateTypeColumn = await knex.schema.hasColumn(TableName.ProjectTemplates, "type");
|
||||||
if (hasTemplateTypeColumn) {
|
if (hasTemplateTypeColumn) {
|
||||||
await knex(TableName.ProjectTemplates).whereNull("type").update({
|
await knex(TableName.ProjectTemplates).whereNull("type").update({
|
||||||
@@ -315,6 +322,9 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
}
|
}
|
||||||
} while (projectsToBeSplit.length > 0);
|
} while (projectsToBeSplit.length > 0);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
await knex.raw(`SET statement_timeout = '${originalTimeout}'`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex: Knex): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user