UNPKG

@coko/server

Version:

Reusable server for use by Coko's projects

39 lines 1.59 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.up = up; exports.down = down; const migrationRunner_1 = __importDefault(require("../migrationRunner")); const migrateDbHelpers_1 = require("../migrateDbHelpers"); const MIGRATIONS_TABLE = 'migrations'; async function up(db) { const migrationRows = await db.table(MIGRATIONS_TABLE); const metaExists = await migrateDbHelpers_1.migrationsMeta.exists(); let checkpoint = null; if (metaExists) { checkpoint = await migrateDbHelpers_1.migrationsMeta.getCheckpoint(); if (checkpoint) await migrateDbHelpers_1.migrationsMeta.clearCheckpoint(); } await db.transaction(async (trx) => { await Promise.all(migrationRows.map(async (row) => { const filename = migrationRunner_1.default.stripMigrationExtensionName(row.id); await db(MIGRATIONS_TABLE) .where({ id: row.id }) .update({ id: filename }) .transacting(trx); })); }); if (metaExists && checkpoint) { await migrateDbHelpers_1.migrationsMeta.setCheckpoint(migrationRunner_1.default.stripMigrationExtensionName(checkpoint)); } } async function down() { /** * There's no coming back, as once the extension is removed, we don't know * what extension to revert back to. */ } //# sourceMappingURL=1762697452-remove-extension-from-migrations.js.map