import { t as configSchema } from "./load-config-B-HgADq2.js";
import path from "node:path";
import { load } from "migrate";
//#region src/migrations.ts
var migrationsLoaders = /* @__PURE__ */ Object.assign({
	"../migrations/1694360000000-create-folders.js": () => import("./1694360000000-create-folders-gBU_ayJo.js"),
	"../migrations/1694360479680-create-account-db.js": () => import("./1694360479680-create-account-db-BegsmvQR.js"),
	"../migrations/1694362247011-create-secret-table.js": () => import("./1694362247011-create-secret-table-B3zgvLMf.js"),
	"../migrations/1702667624000-rename-nordigen-secrets.js": () => import("./1702667624000-rename-nordigen-secrets-DtAALQo0.js"),
	"../migrations/1718889148000-openid.js": () => import("./1718889148000-openid-tdfWy5E-.js"),
	"../migrations/1719409568000-multiuser.js": () => import("./1719409568000-multiuser-Dr3XTPFX.js"),
	"../migrations/1763873568237-server-global-prefs.js": () => import("./1763873568237-server-global-prefs-BOrH9jw1.js"),
	"../migrations/1763873600000-backfill-files-owner.js": () => import("./1763873600000-backfill-files-owner-C5W3n1N0.js")
});
async function run(direction = "up") {
	console.log(`Checking if there are any migrations to run for direction "${direction}"...`);
	try {
		const sortedKeys = Object.keys(migrationsLoaders).sort();
		const migrationsModules = {};
		for (const key of sortedKeys) {
			const fileName = key.split("/").pop();
			migrationsModules[fileName] = await migrationsLoaders[key]();
		}
		return new Promise((resolve, reject) => {
			load({
				stateStore: `${path.join(configSchema.get("dataDir"), ".migrate")}${configSchema.get("mode") === "test" ? "-test" : ""}`,
				migrations: migrationsModules
			}, (err, set) => {
				if (err) return reject(err);
				set[direction]((err) => {
					if (err) return reject(err);
					console.log("Migrations: DONE");
					resolve();
				});
			});
		});
	} catch (err) {
		console.error("Error during migration process:", err);
		throw err;
	}
}
//#endregion
export { run as t };

//# sourceMappingURL=migrations-BM3OCiKK.js.map