mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-19 19:03:36 +00:00
24 lines
900 B
TypeScript
24 lines
900 B
TypeScript
import { Knex } from "knex";
|
|
|
|
import { TableName } from "../schemas";
|
|
|
|
export async function up(knex: Knex): Promise<void> {
|
|
const doesParentColumExist = await knex.schema.hasColumn(TableName.SecretFolder, "parentId");
|
|
const doesNameColumnExist = await knex.schema.hasColumn(TableName.SecretFolder, "name");
|
|
if (doesParentColumExist && doesNameColumnExist) {
|
|
await knex.schema.alterTable(TableName.SecretFolder, (t) => {
|
|
t.index(["parentId", "name"]);
|
|
});
|
|
}
|
|
}
|
|
|
|
export async function down(knex: Knex): Promise<void> {
|
|
const doesParentColumExist = await knex.schema.hasColumn(TableName.SecretFolder, "parentId");
|
|
const doesNameColumnExist = await knex.schema.hasColumn(TableName.SecretFolder, "name");
|
|
if (doesParentColumExist && doesNameColumnExist) {
|
|
await knex.schema.alterTable(TableName.SecretFolder, (t) => {
|
|
t.dropIndex(["parentId", "name"]);
|
|
});
|
|
}
|
|
}
|