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:
Isaias Tavares
2026-11-05 01:15:21 -03:00
committed by Maurice
parent 17b47b38b9
commit 2e3762afe1
176 changed files with 6728 additions and 777 deletions
+27
View File
@@ -27,6 +27,7 @@ import { DayAssignments } from '../../src/db/entities/DayAssignments.entity';
import { Places } from '../../src/db/entities/Places.entity';
import { Reservations } from '../../src/db/entities/Reservations.entity';
import { Trips } from '../../src/db/entities/Trips.entity';
import { AssistantToolCallsRepository } from '../../src/db/repositories/AssistantToolCalls.repository';
import { dbNow } from '../../src/db/types';
import { TURNS_PER_MINUTE } from '../../src/nest/assistant/assistant-tools.constants';
import { AssistantToolsService } from '../../src/nest/assistant/assistant-tools.service';
@@ -661,6 +662,32 @@ describe('Trip assistant e2e', () => {
expect(again.status).toBe(409);
});
it('ASTE2E-026: the change is recorded as failed before the stream ends, however slow the write', async () => {
const t = await travelerWithTrip();
const { toolCallId, threadId } = await proposePlace(t, 'Fushimi Inari');
const open = vi
.spyOn(nestApp.get(AssistantToolsService), 'open')
.mockRejectedValueOnce(new Error('tool session down'));
const record = AssistantToolCallsRepository.prototype.recordOutcome;
const slow = vi.spyOn(AssistantToolCallsRepository.prototype, 'recordOutcome').mockImplementation(async function (
this: AssistantToolCallsRepository,
...args
) {
await new Promise((resolve) => setTimeout(resolve, 100));
return record.apply(this, args);
});
try {
await post(`${t.base}/threads/${threadId}/decisions`, t.userId, {
...CTX,
decisions: [{ toolCallId, approved: true }],
});
expect(await findRow(orm, AssistantToolCalls, { id: toolCallId })).toMatchObject({ state: 'failed' });
} finally {
slow.mockRestore();
open.mockRestore();
}
});
it('ASTE2E-015: an attached file is refused as JSON before the stream when nothing reads it', async () => {
const t = await travelerWithTrip();
const bookingImport = nestApp.get(BookingImportService);