UNPKG

sequelize-typescript-migration-lts

Version:
65 lines 2.3 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const crypto = __importStar(require("crypto")); function parseIndex(idx) { const result = {}; [ "name", "type", "unique", "concurrently", "fields", "using", "operator", "where", ].forEach((key) => { if (idx[key] !== undefined) result[key] = idx[key]; }); const options = {}; if (idx.name) options.indexName = idx.name; // The name of the index. Default is __ // @todo: UNIQUE|FULLTEXT|SPATIAL if (idx.unique) options.type = "UNIQUE"; // Set a type for the index, e.g. BTREE. See the documentation of the used dialect // if (idx.method) { // options["indexType"] = idx.type; // } if (idx.parser && idx.parser !== "") options.parser = idx.parser; // For FULLTEXT columns set your parser result.options = options; // result["hash"] = hash(idx); result.hash = crypto .createHash("sha1") .update(JSON.stringify(idx)) .digest("hex"); return result; } exports.default = parseIndex; //# sourceMappingURL=parseIndex.js.map