mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 17:27:40 +00:00
Fix migration
This commit is contained in:
@@ -4,22 +4,48 @@ import { TableName } from "../schemas";
|
|||||||
|
|
||||||
export async function up(knex: Knex): Promise<void> {
|
export async function up(knex: Knex): Promise<void> {
|
||||||
if (await knex.schema.hasTable(TableName.IdentityUniversalAuth)) {
|
if (await knex.schema.hasTable(TableName.IdentityUniversalAuth)) {
|
||||||
await knex.schema.alterTable(TableName.IdentityUniversalAuth, (t) => {
|
const hasLockoutEnabled = await knex.schema.hasColumn(TableName.IdentityUniversalAuth, "lockoutEnabled");
|
||||||
|
const hasLockoutThreshold = await knex.schema.hasColumn(TableName.IdentityUniversalAuth, "lockoutThreshold");
|
||||||
|
const hasLockoutDuration = await knex.schema.hasColumn(TableName.IdentityUniversalAuth, "lockoutDuration");
|
||||||
|
const hasLockoutCounterReset = await knex.schema.hasColumn(TableName.IdentityUniversalAuth, "lockoutCounterReset");
|
||||||
|
|
||||||
|
await knex.schema.alterTable(TableName.IdentityUniversalAuth, async (t) => {
|
||||||
|
if (!hasLockoutEnabled) {
|
||||||
t.boolean("lockoutEnabled").notNullable().defaultTo(true);
|
t.boolean("lockoutEnabled").notNullable().defaultTo(true);
|
||||||
|
}
|
||||||
|
if (!hasLockoutThreshold) {
|
||||||
t.integer("lockoutThreshold").notNullable().defaultTo(3);
|
t.integer("lockoutThreshold").notNullable().defaultTo(3);
|
||||||
|
}
|
||||||
|
if (!hasLockoutDuration) {
|
||||||
t.integer("lockoutDuration").notNullable().defaultTo(300); // 5 minutes (in seconds)
|
t.integer("lockoutDuration").notNullable().defaultTo(300); // 5 minutes (in seconds)
|
||||||
|
}
|
||||||
|
if (!hasLockoutCounterReset) {
|
||||||
t.integer("lockoutCounterReset").notNullable().defaultTo(30); // 30 seconds
|
t.integer("lockoutCounterReset").notNullable().defaultTo(30); // 30 seconds
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function down(knex: Knex): Promise<void> {
|
export async function down(knex: Knex): Promise<void> {
|
||||||
if (await knex.schema.hasTable(TableName.IdentityUniversalAuth)) {
|
if (await knex.schema.hasTable(TableName.IdentityUniversalAuth)) {
|
||||||
|
const hasLockoutEnabled = await knex.schema.hasColumn(TableName.IdentityUniversalAuth, "lockoutEnabled");
|
||||||
|
const hasLockoutThreshold = await knex.schema.hasColumn(TableName.IdentityUniversalAuth, "lockoutThreshold");
|
||||||
|
const hasLockoutDuration = await knex.schema.hasColumn(TableName.IdentityUniversalAuth, "lockoutDuration");
|
||||||
|
const hasLockoutCounterReset = await knex.schema.hasColumn(TableName.IdentityUniversalAuth, "lockoutCounterReset");
|
||||||
|
|
||||||
await knex.schema.alterTable(TableName.IdentityUniversalAuth, (t) => {
|
await knex.schema.alterTable(TableName.IdentityUniversalAuth, (t) => {
|
||||||
|
if (hasLockoutEnabled) {
|
||||||
t.dropColumn("lockoutEnabled");
|
t.dropColumn("lockoutEnabled");
|
||||||
|
}
|
||||||
|
if (hasLockoutThreshold) {
|
||||||
t.dropColumn("lockoutThreshold");
|
t.dropColumn("lockoutThreshold");
|
||||||
|
}
|
||||||
|
if (hasLockoutDuration) {
|
||||||
t.dropColumn("lockoutDuration");
|
t.dropColumn("lockoutDuration");
|
||||||
|
}
|
||||||
|
if (hasLockoutCounterReset) {
|
||||||
t.dropColumn("lockoutCounterReset");
|
t.dropColumn("lockoutCounterReset");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user