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.
18 lines
550 B
TypeScript
18 lines
550 B
TypeScript
// Generated by scripts/generate-db-types.ts from the migrated schema. Do not edit by hand:
|
|
// change the migration, then run `npm run gen:db-types`.
|
|
|
|
import type { InsertOptional } from './columns';
|
|
|
|
export interface PushSubscriptionsTable {
|
|
id: InsertOptional<number>;
|
|
user_id: number;
|
|
endpoint: string;
|
|
p256dh: string;
|
|
auth: string;
|
|
vapid_public_key: string;
|
|
user_agent: InsertOptional<string | null>;
|
|
created_at: InsertOptional<string>;
|
|
last_success_at: InsertOptional<string | null>;
|
|
failure_count: InsertOptional<number>;
|
|
}
|