mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +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:
@@ -17,6 +17,7 @@
|
||||
* asserts the plugin still comes up clean.
|
||||
*/
|
||||
import { db as testDb } from '../../../src/db/database';
|
||||
import { SqliteEngine } from '../../../src/db/engine/sqlite/sqlite-engine';
|
||||
import { Addons } from '../../../src/db/entities/Addons.entity';
|
||||
import { AppSettings } from '../../../src/db/entities/AppSettings.entity';
|
||||
import { AuditLog } from '../../../src/db/entities/AuditLog.entity';
|
||||
@@ -173,7 +174,7 @@ describe('plugin boot vs registry scan ordering', () => {
|
||||
(t as TestOrm).repo(NotificationChannelPreferences),
|
||||
// Plan 4 Task 4: `uow` is no longer `@Optional()` — ordered ahead
|
||||
// of `registry?`/`hostFactory?`, matching the real constructor.
|
||||
new UnitOfWork((t as TestOrm).em),
|
||||
new UnitOfWork((t as TestOrm).em, new SqliteEngine()),
|
||||
undefined,
|
||||
hostFactory,
|
||||
t?.orm,
|
||||
@@ -264,7 +265,7 @@ describe('plugin boot vs registry scan ordering', () => {
|
||||
t2.repo(PhotoProviderFields),
|
||||
t2.repo(AppSettings),
|
||||
t2.repo(Users),
|
||||
new UnitOfWork(t2.em),
|
||||
new UnitOfWork(t2.em, new SqliteEngine()),
|
||||
);
|
||||
const auditLogRepo2 = t2.repo(AuditLog);
|
||||
const usersRepo2 = t2.repo(Users);
|
||||
@@ -293,7 +294,7 @@ describe('plugin boot vs registry scan ordering', () => {
|
||||
t2.repo(PluginCapabilityAudit),
|
||||
t2.repo(Settings),
|
||||
t2.repo(NotificationChannelPreferences),
|
||||
new UnitOfWork(t2.em),
|
||||
new UnitOfWork(t2.em, new SqliteEngine()),
|
||||
undefined,
|
||||
hostFactory2,
|
||||
t2.orm,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* so every one of the 14 repositories this task injects reads/writes real columns,
|
||||
* not a hand-slimmed fixture table.
|
||||
*/
|
||||
import { SqliteEngine } from '../../../src/db/engine/sqlite/sqlite-engine';
|
||||
import { AuditLog } from '../../../src/db/entities/AuditLog.entity';
|
||||
import { NotificationChannelPreferences } from '../../../src/db/entities/NotificationChannelPreferences.entity';
|
||||
import { PluginActions } from '../../../src/db/entities/PluginActions.entity';
|
||||
@@ -76,7 +77,7 @@ async function buildRuntime(registrar?: CronRegistrarService): Promise<PluginRun
|
||||
const audit = new AuditService(t.repo(AuditLog), t.repo(Users));
|
||||
const addons = await createTestAddonsService(testDb);
|
||||
const userSettings = new PluginUserSettingsService(t.repo(PluginSettingsFields), t.repo(PluginUserConfig));
|
||||
const uow = new UnitOfWork(t.em);
|
||||
const uow = new UnitOfWork(t.em, new SqliteEngine());
|
||||
return new PluginRuntimeService(
|
||||
audit,
|
||||
addons,
|
||||
@@ -218,7 +219,7 @@ describe('Plan 3j Task 2 — R-install-gates named accept+refuse pairs (PR17/PR2
|
||||
t.repo(PluginCapabilityAudit),
|
||||
t.repo(Settings),
|
||||
t.repo(NotificationChannelPreferences),
|
||||
new UnitOfWork(t.em),
|
||||
new UnitOfWork(t.em, new SqliteEngine()),
|
||||
fakeRegistry(['db:own']),
|
||||
);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -254,7 +255,7 @@ describe('Plan 3j Task 2 — R-install-gates named accept+refuse pairs (PR17/PR2
|
||||
t.repo(PluginCapabilityAudit),
|
||||
t.repo(Settings),
|
||||
t.repo(NotificationChannelPreferences),
|
||||
new UnitOfWork(t.em),
|
||||
new UnitOfWork(t.em, new SqliteEngine()),
|
||||
fakeRegistry(['db:own', 'db:read:trips']),
|
||||
);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -303,7 +304,7 @@ describe('Plan 3j Task 2 — R-install-gates named accept+refuse pairs (PR17/PR2
|
||||
t.repo(PluginCapabilityAudit),
|
||||
t.repo(Settings),
|
||||
t.repo(NotificationChannelPreferences),
|
||||
new UnitOfWork(t.em),
|
||||
new UnitOfWork(t.em, new SqliteEngine()),
|
||||
registry,
|
||||
);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -342,7 +343,7 @@ describe('Plan 3j Task 2 — R-install-gates named accept+refuse pairs (PR17/PR2
|
||||
t.repo(PluginCapabilityAudit),
|
||||
t.repo(Settings),
|
||||
t.repo(NotificationChannelPreferences),
|
||||
new UnitOfWork(t.em),
|
||||
new UnitOfWork(t.em, new SqliteEngine()),
|
||||
registry,
|
||||
);
|
||||
await expect(rtR.retrust('pr28-refuse', '2.0.0', 'NEWKEY', { userId: 1 })).rejects.toThrow(/nothing to re-trust/);
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
* plugin-runtime.service.ts's own comment at the wrap site) already ran inside a
|
||||
* request context by the time this file's shared `runtime` finished booting.
|
||||
*/
|
||||
import { SqliteEngine } from '../../../src/db/engine/sqlite/sqlite-engine';
|
||||
import { AuditLog } from '../../../src/db/entities/AuditLog.entity';
|
||||
import { NotificationChannelPreferences } from '../../../src/db/entities/NotificationChannelPreferences.entity';
|
||||
import { PluginActions } from '../../../src/db/entities/PluginActions.entity';
|
||||
@@ -158,7 +159,7 @@ async function buildRuntime(registrar?: CronRegistrarService, orm?: TestOrm['orm
|
||||
t.repo(Settings),
|
||||
t.repo(NotificationChannelPreferences),
|
||||
// Plan 4 Task 4: `uow` is no longer `@Optional()`.
|
||||
new UnitOfWork(t.em),
|
||||
new UnitOfWork(t.em, new SqliteEngine()),
|
||||
undefined,
|
||||
undefined,
|
||||
orm,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* install a pinned version through the full verify -> extract -> validate ->
|
||||
* move -> register pipeline (with the network download mocked).
|
||||
*/
|
||||
import { SqliteEngine } from '../../../src/db/engine/sqlite/sqlite-engine';
|
||||
import { PluginActions } from '../../../src/db/entities/PluginActions.entity';
|
||||
import { PluginErrorLog } from '../../../src/db/entities/PluginErrorLog.entity';
|
||||
import { PluginSettingsFields } from '../../../src/db/entities/PluginSettingsFields.entity';
|
||||
@@ -148,7 +149,7 @@ beforeEach(() => {
|
||||
t.repo(PluginActions),
|
||||
t.repo(PluginSettingsFields),
|
||||
t.repo(PluginErrorLog),
|
||||
new UnitOfWork(t.em),
|
||||
new UnitOfWork(t.em, new SqliteEngine()),
|
||||
);
|
||||
});
|
||||
afterEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user