UNPKG

n8n

Version:

n8n Workflow Automation Tool

45 lines 1.9 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DropIndex = exports.CreateIndex = void 0; const typeorm_1 = require("@n8n/typeorm"); const p_lazy_1 = __importDefault(require("p-lazy")); class IndexOperation extends p_lazy_1.default { get fullTableName() { return [this.tablePrefix, this.tableName].join(''); } get fullIndexName() { return ['IDX', `${this.tablePrefix}${this.tableName}`, ...this.columnNames].join('_'); } constructor(tableName, columnNames, tablePrefix, queryRunner, customIndexName) { super((resolve) => { void this.execute(queryRunner).then(resolve); }); this.tableName = tableName; this.columnNames = columnNames; this.tablePrefix = tablePrefix; this.customIndexName = customIndexName; } } class CreateIndex extends IndexOperation { constructor(tableName, columnNames, isUnique, tablePrefix, queryRunner, customIndexName) { super(tableName, columnNames, tablePrefix, queryRunner, customIndexName); this.isUnique = isUnique; } async execute(queryRunner) { var _a; const { columnNames, isUnique } = this; return await queryRunner.createIndex(this.fullTableName, new typeorm_1.TableIndex({ name: (_a = this.customIndexName) !== null && _a !== void 0 ? _a : this.fullIndexName, columnNames, isUnique })); } } exports.CreateIndex = CreateIndex; class DropIndex extends IndexOperation { async execute(queryRunner) { var _a; return await queryRunner.dropIndex(this.fullTableName, (_a = this.customIndexName) !== null && _a !== void 0 ? _a : this.fullIndexName); } } exports.DropIndex = DropIndex; //# sourceMappingURL=Indices.js.map