mirror of
https://github.com/Infisical/infisical.git
synced 2025-08-03 20:23:35 +00:00
22 lines
780 B
TypeScript
22 lines
780 B
TypeScript
import { Knex } from "knex";
|
|
|
|
import { TableName } from "../schemas";
|
|
|
|
export async function up(knex: Knex): Promise<void> {
|
|
const doesSnapshotIdExist = await knex.schema.hasColumn(TableName.SnapshotSecret, "snapshotId");
|
|
if (await knex.schema.hasTable(TableName.SnapshotSecret)) {
|
|
await knex.schema.alterTable(TableName.SnapshotSecret, (t) => {
|
|
if (doesSnapshotIdExist) t.index("snapshotId");
|
|
});
|
|
}
|
|
}
|
|
|
|
export async function down(knex: Knex): Promise<void> {
|
|
const doesSnapshotIdExist = await knex.schema.hasColumn(TableName.SnapshotSecret, "snapshotId");
|
|
if (await knex.schema.hasTable(TableName.SnapshotSecret)) {
|
|
await knex.schema.alterTable(TableName.SnapshotSecret, (t) => {
|
|
if (doesSnapshotIdExist) t.dropIndex("snapshotId");
|
|
});
|
|
}
|
|
}
|