UNPKG

n8n

Version:

n8n Workflow Automation Tool

50 lines 2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DbRevertMigrationCommand = void 0; const command_1 = require("@oclif/command"); const typeorm_1 = require("typeorm"); const n8n_workflow_1 = require("n8n-workflow"); const Logger_1 = require("../../src/Logger"); const src_1 = require("../../src"); class DbRevertMigrationCommand extends command_1.Command { async run() { var _a; const logger = Logger_1.getLogger(); n8n_workflow_1.LoggerProxy.init(logger); const { flags } = this.parse(DbRevertMigrationCommand); let connection; try { await src_1.Db.init(); connection = (_a = src_1.Db.collections.Credentials) === null || _a === void 0 ? void 0 : _a.manager.connection; if (!connection) { throw new Error(`No database connection available.`); } const connectionOptions = Object.assign(connection.options, { subscribers: [], synchronize: false, migrationsRun: false, dropSchema: false, logging: ['query', 'error', 'schema'], }); await connection.close(); connection = await typeorm_1.createConnection(connectionOptions); await connection.undoLastMigration(); await connection.close(); } catch (error) { if (connection) await connection.close(); console.error('Error reverting last migration. See log messages for details.'); logger.error(error.message); this.exit(1); } this.exit(); } } exports.DbRevertMigrationCommand = DbRevertMigrationCommand; DbRevertMigrationCommand.description = 'Revert last database migration'; DbRevertMigrationCommand.examples = ['$ n8n db:revert']; DbRevertMigrationCommand.flags = { help: command_1.flags.help({ char: 'h' }), }; //# sourceMappingURL=revert.js.map