Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

add index on secret snapshot folders

Maidul Islamf4de52e714d3
diff --git a/backend/src/db/migrations/20240522221147_secret-snapshot-folder-index-on-snapshotId.ts b/backend/src/db/migrations/20240522221147_secret-snapshot-folder-index-on-snapshotId.ts
new file mode 100644
index 0000000000..ffb7c3336f
--- /dev/null
+++ b/backend/src/db/migrations/20240522221147_secret-snapshot-folder-index-on-snapshotId.ts
@@ -0,0 +1,21 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+export async function up(knex: Knex): Promise<void> {
+ const doesSnapshotIdExist = await knex.schema.hasColumn(TableName.SnapshotFolder, "snapshotId");
+ if (await knex.schema.hasTable(TableName.SnapshotFolder)) {
+ await knex.schema.alterTable(TableName.SnapshotFolder, (t) => {
+ if (doesSnapshotIdExist) t.index("snapshotId");
+ });
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ const doesSnapshotIdExist = await knex.schema.hasColumn(TableName.SnapshotFolder, "snapshotId");
+ if (await knex.schema.hasTable(TableName.SnapshotFolder)) {
+ await knex.schema.alterTable(TableName.SnapshotFolder, (t) => {
+ if (doesSnapshotIdExist) t.dropIndex("snapshotId");
+ });
+ }
+}