mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
feat(db): keep SQLite's write and search semantics on Postgres
- UnitOfWork transactions take one advisory lock for the database on Postgres (DatabaseEngine.serializeWrites, pg_advisory_xact_lock), so a MAX(...) + 1 read inside one cannot race another, as with SQLite's single writer. SQLite needs nothing. - ilike(platform, refs) builds the case-insensitive search condition: LIKE on SQLite, ILIKE on Postgres, where LIKE is exact. The place searches use it. - Plugin data erasure runs each statement in its own savepoint: on Postgres a failed statement would abort the user's whole erasure transaction.
This commit is contained in:
@@ -3,6 +3,7 @@ import { resolveDbPath } from '../../db-path';
|
||||
import { runSchemaBootstrap, type AnyOrm } from '../../orm';
|
||||
import { SharedSqliteDriver } from '../../orm-driver';
|
||||
import type { DatabaseEngine } from '../engine';
|
||||
import type { EntityManager } from '@mikro-orm/core';
|
||||
|
||||
/**
|
||||
* The SQLite file engine, TREK's default: one better-sqlite3 handle that
|
||||
@@ -40,4 +41,9 @@ export class SqliteEngine implements DatabaseEngine {
|
||||
schemaBootstrap(orm: AnyOrm, options: { snapshot: boolean }): Promise<void> {
|
||||
return runSchemaBootstrap(orm, options);
|
||||
}
|
||||
|
||||
serializeWrites(_em: EntityManager): Promise<void> {
|
||||
// One connection, one writer: SQLite serializes the transactions already.
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user