fase(2): shared infrastructure layer

This commit is contained in:
debian
2026-03-04 16:26:32 -05:00
parent 0e6c0c3655
commit 4a58749048
21 changed files with 1170 additions and 23 deletions

31
dist/db/migrator.js vendored Normal file
View File

@@ -0,0 +1,31 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runMigrations = runMigrations;
const kysely_1 = require("kysely");
const path_1 = __importDefault(require("path"));
const promises_1 = __importDefault(require("fs/promises"));
async function runMigrations(db) {
const migrator = new kysely_1.Migrator({
db,
provider: new kysely_1.FileMigrationProvider({
fs: promises_1.default,
path: path_1.default,
migrationFolder: path_1.default.join(__dirname, 'migrations'),
}),
});
const { error, results } = await migrator.migrateToLatest();
results?.forEach(result => {
if (result.status === 'Success') {
console.log(`Migration "${result.migrationName}" executed successfully`);
}
else if (result.status === 'Error') {
console.error(`Migration "${result.migrationName}" failed`);
}
});
if (error) {
throw error;
}
}