"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
const _PlatformTools = require("typeorm/platform/PlatformTools");
const _CommandUtils = require("typeorm/commands/CommandUtils");
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
async function main() {
    let dataSource = undefined;
    try {
        dataSource = await _CommandUtils.CommandUtils.loadDataSource(_path.default.resolve(process.cwd(), "dist/data-source.js"));
        dataSource.setOptions({
            subscribers: [],
            synchronize: false,
            migrationsRun: false,
            dropSchema: false,
            logging: [
                "query",
                "error",
                "schema"
            ]
        });
        await dataSource.initialize();
        const options = {
            transaction: dataSource.options.migrationsTransactionMode ?? "all"
        };
        options.transaction = "all";
        await dataSource.runMigrations(options);
        await dataSource.destroy();
    } catch (err) {
        _PlatformTools.PlatformTools.logCmdErr("Error during migration run:", err);
        if (dataSource && dataSource.isInitialized) await dataSource.destroy();
        process.exit(1);
    }
}
let start = new Date().getTime();
main().then(()=>{
    let end = new Date().getTime();
    console.log("done", end - start, "ms");
    process.exit(0);
});

//# sourceMappingURL=typeorm-migrate.js.map