mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
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.
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
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 WAL checkpoint,
|
||||
* `VACUUM INTO`, the plugin-table erasure).
|
||||
* statements no entity can express (the readiness ping, the plugin-table
|
||||
* erasure), and `SqliteMaintenance`, the SQLite file's own (the WAL
|
||||
* checkpoint, `VACUUM INTO`).
|
||||
*
|
||||
* A factory over the context-resolving global `EntityManager`, the same one
|
||||
* Nest injects into every service, so the repository resolves the request or
|
||||
* 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/`.
|
||||
*/
|
||||
@@ -19,7 +21,12 @@ import { Module } from '@nestjs/common';
|
||||
useFactory: (em: EntityManager) => new MaintenanceRepository(em),
|
||||
inject: [EntityManager],
|
||||
},
|
||||
{
|
||||
provide: SqliteMaintenance,
|
||||
useFactory: (em: EntityManager) => new SqliteMaintenance(em),
|
||||
inject: [EntityManager],
|
||||
},
|
||||
],
|
||||
exports: [MaintenanceRepository],
|
||||
exports: [MaintenanceRepository, SqliteMaintenance],
|
||||
})
|
||||
export class MaintenanceModule {}
|
||||
|
||||
Reference in New Issue
Block a user