@jsgurucompany/jsg-nestjs-common
Version:
Initial README.md
85 lines • 3.28 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MigratorCommand = void 0;
const common_1 = require("@nestjs/common");
const const_1 = require("../const");
const nestjs_command_1 = require("nestjs-command");
let MigratorCommand = class MigratorCommand {
constructor(migrator) {
this.migrator = migrator;
}
async up() {
await this.migrator.up();
}
async down() {
await this.migrator.down();
}
async reset() {
await this.migrator.down({ to: 0 });
}
async createMigration(migration) {
await this.migrator.create({
name: migration,
});
}
};
__decorate([
(0, nestjs_command_1.Command)({
command: 'migrate',
describe: 'Performs database migrations',
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], MigratorCommand.prototype, "up", null);
__decorate([
(0, nestjs_command_1.Command)({
command: 'migrate:down',
describe: 'Reverts database migrations',
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], MigratorCommand.prototype, "down", null);
__decorate([
(0, nestjs_command_1.Command)({
command: 'migrate:reset',
describe: 'Reverts database migrations',
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], MigratorCommand.prototype, "reset", null);
__decorate([
(0, nestjs_command_1.Command)({
command: 'migration:create <migration>',
describe: 'Create new migration file',
}),
__param(0, (0, nestjs_command_1.Positional)({
name: 'migration',
describe: 'Name of the migration file',
type: 'string',
})),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], MigratorCommand.prototype, "createMigration", null);
MigratorCommand = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, common_1.Inject)(const_1.MIGRATOR_TOKEN)),
__metadata("design:paramtypes", [Object])
], MigratorCommand);
exports.MigratorCommand = MigratorCommand;
//# sourceMappingURL=migrator.command.js.map