--- status: accepted date: 2026-06-01 supersedes: ADR-005, ADR-018 --- # ADR-046: Fold @alkdev/drizzlebox as src/sqlite/utils/ ## Context `@alkdev/drizzlebox` (a fork of `drizzle-typebox` adapted for `@alkdev/typebox`) provides `createSelectSchema` and `createInsertSchema` functions that derive TypeBox validation schemas from Drizzle table definitions. It is consumed as an external npm dependency by all SQLite table files in `@alkdev/storage`. The parent project `@alkdev/dbtype` also planned a Phase 1 (UJSX→HostConfig →Drizzle pipeline) that was never implemented. With SQLite as the sole database target (ADR-038), the multi-dialect column mappings in dbtype (PG, MySQL, SingleStore) are dead weight for storage. ADR-018 deferred dbtype integration to post-v1. But the fold of just the Phase 0 subset (column→TypeBox mappings + schema generation) is a straightforward import path change with no behavioral difference. ## Decision Fold the SQLite-only subset of `@alkdev/dbtype` Phase 0 into `src/sqlite/utils/`: | Source (dbtype) | Target (storage) | Changes | |-----------------|-------------------|---------| | `schema.ts` | `utils/schema.ts` | Remove PgEnum handling. Keep createSelectSchema, createInsertSchema, createUpdateSchema. | | `column.ts` | `utils/column.ts` | Strip PG, MySQL, SingleStore branches. Keep SQLiteInteger, SQLiteReal, SQLiteText + generic dataType dispatch. | | `schema.types.ts` + `schema.types.internal.ts` + `column.types.ts` | `utils/types.ts` | Merged. Remove PgEnum overloads. | | `constants.ts` | `utils/constants.ts` | Keep as-is. | | `utils.ts` | `utils/utils.ts` | Remove PgEnum alias. Keep isColumnType, isWithEnum, JsonSchema, BufferSchema. | All table files change their import from `@alkdev/drizzlebox` to `../utils/schema.ts`. ## Consequences - **No external drizzlebox dependency** — one fewer npm package in the dependency graph. - **SQLite-only column mappings** — dead multi-dialect code removed. If a new database host is added later, mappings would need to be re-added. - **Same API surface** — `createSelectSchema`, `createInsertSchema`, `createUpdateSchema` produce the same TypeBox schemas. - **Co-located with tables** — utility code lives next to the tables it derives schemas from. Easier to maintain. - **dbtype Phase 1 (UJSX→HostConfig) not affected** — that remains a separate architectural concern, could live in storage or as its own package when built.