"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "checkIsMigrationContextAvailable", {
    enumerable: true,
    get: function() {
        return checkIsMigrationContextAvailable;
    }
});
const checkIsMigrationContextAvailable = async (sequelize)=>{
    try {
        await sequelize.query('SAVEPOINT _migration_context_probe');
        await sequelize.query("SELECT public.set_session_config('tamanu._migration_probe', '', true)");
        await sequelize.query('RELEASE SAVEPOINT _migration_context_probe');
        return true;
    } catch  {
        try {
            await sequelize.query('ROLLBACK TO SAVEPOINT _migration_context_probe');
        } catch  {
        // Savepoint may not exist if the connection is in a bad state.
        }
        return false;
    }
};

//# sourceMappingURL=checkIsMigrationContextAvailable.js.map