@apilogic/migration-tool-api
Version:
Universal sql/no-sql database serverless migration tool
37 lines • 1.11 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Migration = void 0;
const uuid_1 = require("uuid");
class Migration {
constructor({ id, vid, file, isApplied, dataAPI, migrationAPI }) {
this.id = id;
this.vid = vid;
this.file = file;
this.isApplied = isApplied;
this.dataAPI = dataAPI;
this.migrationAPI = migrationAPI;
}
async apply() {
var _a;
if (this.isApplied) {
return;
}
const that = this.file;
const workingDir = this.file.match(/(.*)[/\\]/)[1] || '';
const { up } = await (_a = that, Promise.resolve().then(() => require(_a)));
await up(this.dataAPI, workingDir);
await this.migrationAPI.load(this.insertPayload());
}
insertPayload() {
return {
version: '2017-02-28',
operation: 'PutItem',
item: {
id: (0, uuid_1.v4)(),
migration_id: this.id,
}
};
}
}
exports.Migration = Migration;
//# sourceMappingURL=Migration.js.map
;