mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 11:27:47 +00:00
Update migration
This commit is contained in:
@@ -24,6 +24,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
t.string("url").nullable().alter();
|
t.string("url").nullable().alter();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!hasEncryptedCredentials) {
|
||||||
const superAdminDAL = superAdminDALFactory(knex);
|
const superAdminDAL = superAdminDALFactory(knex);
|
||||||
const envConfig = await getMigrationEnvConfig(superAdminDAL);
|
const envConfig = await getMigrationEnvConfig(superAdminDAL);
|
||||||
const keyStore = inMemoryKeyStore();
|
const keyStore = inMemoryKeyStore();
|
||||||
@@ -116,6 +117,7 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// IMPORTANT: The down migration does not utilize the existing "url" and encrypted header columns
|
// IMPORTANT: The down migration does not utilize the existing "url" and encrypted header columns
|
||||||
// because we're taking the latest data from the credentials column and re-encrypting it into relevant columns
|
// because we're taking the latest data from the credentials column and re-encrypting it into relevant columns
|
||||||
@@ -125,6 +127,10 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex: Knex): Promise<void> {
|
||||||
if (await knex.schema.hasTable(TableName.AuditLogStream)) {
|
if (await knex.schema.hasTable(TableName.AuditLogStream)) {
|
||||||
|
const hasProvider = await knex.schema.hasColumn(TableName.AuditLogStream, "provider");
|
||||||
|
const hasEncryptedCredentials = await knex.schema.hasColumn(TableName.AuditLogStream, "encryptedCredentials");
|
||||||
|
|
||||||
|
if (hasEncryptedCredentials) {
|
||||||
const superAdminDAL = superAdminDALFactory(knex);
|
const superAdminDAL = superAdminDALFactory(knex);
|
||||||
const envConfig = await getMigrationEnvConfig(superAdminDAL);
|
const envConfig = await getMigrationEnvConfig(superAdminDAL);
|
||||||
const keyStore = inMemoryKeyStore();
|
const keyStore = inMemoryKeyStore();
|
||||||
@@ -203,12 +209,13 @@ export async function down(knex: Knex): Promise<void> {
|
|||||||
void qb.whereNot("provider", "custom").orWhereNull("url");
|
void qb.whereNot("provider", "custom").orWhereNull("url");
|
||||||
})
|
})
|
||||||
.del();
|
.del();
|
||||||
|
}
|
||||||
|
|
||||||
await knex.schema.alterTable(TableName.AuditLogStream, (t) => {
|
await knex.schema.alterTable(TableName.AuditLogStream, (t) => {
|
||||||
t.string("url").notNullable().alter();
|
t.string("url").notNullable().alter();
|
||||||
|
|
||||||
t.dropColumn("provider");
|
if (hasProvider) t.dropColumn("provider");
|
||||||
t.dropColumn("encryptedCredentials");
|
if (hasEncryptedCredentials) t.dropColumn("encryptedCredentials");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user