mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
5f17a5df50
The repositories typed their Kysely statements against 159 table interfaces written by hand, one or more per repository. Nothing compared them with the schema: a migration that renamed a column or changed its type left them stale while tsc stayed green, and several had already drifted (reservations.accommodation_id is TEXT, not INTEGER). scripts/generate-db-types.ts migrates a throwaway database with the real migrations, reads every table back and writes one interface per table into src/db/kysely/ plus the DB map in db.ts. Every hand-written interface is now Pick<DB, ...> of that type, and npm run check:db-types fails when the committed files no longer match the migrations. A column an insert may leave out (rowid, DEFAULT, nullable) is InsertOptional<T>, declared as ColumnType<T, T | void, T>. The server compiles without strictNullChecks, where Kysely's own Generated<T> still demands the column; that is why the old code kept separate insert-only interfaces. The ids callers pass as number | string are cast to the column type at the bind, so every statement binds the same value as before.
25 lines
1.0 KiB
JSON
25 lines
1.0 KiB
JSON
{
|
|
"scripts/db-call-graph.mjs": 1036,
|
|
"scripts/generate-entities.ts": 2259,
|
|
"src/db/dialect/sql-functions.ts": 1007,
|
|
"src/db/repositories/Places.repository.ts": 1440,
|
|
"src/db/repositories/Reservations.repository.ts": 1676,
|
|
"src/db/repositories/Trips.repository.ts": 1121,
|
|
"src/db/repositories/Users.repository.ts": 1710,
|
|
"src/nest/atlas/atlas-geo.ts": 1005,
|
|
"src/nest/atlas/atlas.service.ts": 1182,
|
|
"src/nest/auth/auth.service.ts": 1166,
|
|
"src/nest/budget/budget.service.ts": 1703,
|
|
"src/nest/collections/collections.service.ts": 1488,
|
|
"src/nest/doc-sync/doc-sync.service.ts": 1060,
|
|
"src/nest/doc-sync/providers/synology-drive.client.ts": 1160,
|
|
"src/nest/journey/journey-domain.service.ts": 1806,
|
|
"src/nest/maps/maps.service.ts": 3252,
|
|
"src/nest/places/places.service.ts": 2022,
|
|
"src/nest/plugins/plugin-runtime.service.ts": 1472,
|
|
"src/nest/plugins/runtime/plugin-sdk.ts": 1094,
|
|
"src/nest/reservations/reservations.service.ts": 1248,
|
|
"src/nest/trips/trips.service.ts": 1014,
|
|
"src/nest/vacay/vacay.service.ts": 1442
|
|
}
|