pg-node-migrations
Version:
Based on the work on ThomWright's postgres migration package. Adds the ability to specify a schema and table name.
19 lines (18 loc) • 732 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadSqlFromJs = void 0;
const path = require("path");
const loadSqlFromJs = (filePath) => {
const migrationModule = require(filePath);
if (!migrationModule.generateSql) {
throw new Error(`Invalid javascript migration file: '${path.basename(filePath)}'.
It must to export a 'generateSql' function.`);
}
const generatedValue = migrationModule.generateSql();
if (typeof generatedValue !== "string") {
throw new Error(`Invalid javascript migration file: '${path.basename(filePath)}'.
'generateSql' function must return a string literal.`);
}
return generatedValue;
};
exports.loadSqlFromJs = loadSqlFromJs;