Files
TREK/server/src/nest/database/maintenance.module.ts
T
Isaias Tavares 2e3762afe1 feat(db): run TREK on PostgreSQL
TREK runs on PostgreSQL when TREK_DB_URL is set, and on SQLite as before
otherwise: an engine port under src/db/engine, the dialect helpers under
src/db/dialect, a Postgres baseline for the migrations up to the cut,
pg_dump/pg_restore backups, a probe of every repository method against a
real server and a Postgres test lane in CI.
2026-11-17 23:03:33 +01:00

33 lines
1.2 KiB
TypeScript

import { SqliteMaintenance } from '../../db/engine/sqlite/sqlite-maintenance';
import { MaintenanceRepository } from '../../db/repositories/MaintenanceRepository';
import { EntityManager } from '@mikro-orm/core';
import { Module } from '@nestjs/common';
/**
* Provides `MaintenanceRepository`, the home of the few whole-database
* statements no entity can express (the readiness ping, the plugin-table
* erasure), and `SqliteMaintenance`, the SQLite file's own (the WAL
* checkpoint, `VACUUM INTO`).
*
* Factories over the context-resolving global `EntityManager`, the same one
* Nest injects into every service, so each resolves the request or
* transaction fork that is active when a method runs. The class itself stays
* free of Nest, like every other file under `db/`.
*/
@Module({
providers: [
{
provide: MaintenanceRepository,
useFactory: (em: EntityManager) => new MaintenanceRepository(em),
inject: [EntityManager],
},
{
provide: SqliteMaintenance,
useFactory: (em: EntityManager) => new SqliteMaintenance(em),
inject: [EntityManager],
},
],
exports: [MaintenanceRepository, SqliteMaintenance],
})
export class MaintenanceModule {}