fix(#9): drop pgTable variants, switch storage layer to sqlite-only #11

Closed
Mark wants to merge 1 commit from fix/9-drizzle-overload into main
Owner

Fixes #9.

drizzle-orm 0.39.3 with TypeScript 5.6.3 cannot reconcile the union of pgTable + sqliteTable variants declared in shared/schema.ts. storage.ts operates on db whose type is the union of node-postgres and better-sqlite3 adapters, and every .select/.insert/.update/.delete call site fails with TS2349.

Codebase is unambiguously SQLite at runtime: dev.db is committed, CI workflow doesn't set DATABASE_URL, better-sqlite3 is the actual driver. Switch to sqlite-only.

  • shared/schema.ts: drop pgTable imports and the *Sqlite duplicates; the canonical table exports are now sqliteTable-backed.
  • server/db.ts: SQLite-only; DATABASE_URL used only when it doesn't look like a postgres URL.
  • script/migrate.ts, drizzle.config.ts, server/test/setup.ts: follow the SQLite-only change.
  • server/storage.ts: ISO-string dates for text columns; default optional email to '' on insert.
  • server/routes.ts: import Relationship/Action types; String()-coerce req.params.id.
  • server/index.ts: reshape logger.error call to fit (string, string?).

Verified:

  • npm run check exits 0 (was 30+ errors).
  • npm run build succeeds.
  • npx vitest run: 10/10 tests pass.

Unblocks #7.

Fixes #9. drizzle-orm 0.39.3 with TypeScript 5.6.3 cannot reconcile the union of pgTable + sqliteTable variants declared in shared/schema.ts. storage.ts operates on db whose type is the union of node-postgres and better-sqlite3 adapters, and every .select/.insert/.update/.delete call site fails with TS2349. Codebase is unambiguously SQLite at runtime: dev.db is committed, CI workflow doesn't set DATABASE_URL, better-sqlite3 is the actual driver. Switch to sqlite-only. - shared/schema.ts: drop pgTable imports and the *Sqlite duplicates; the canonical table exports are now sqliteTable-backed. - server/db.ts: SQLite-only; DATABASE_URL used only when it doesn't look like a postgres URL. - script/migrate.ts, drizzle.config.ts, server/test/setup.ts: follow the SQLite-only change. - server/storage.ts: ISO-string dates for text columns; default optional email to '' on insert. - server/routes.ts: import Relationship/Action types; String()-coerce req.params.id. - server/index.ts: reshape logger.error call to fit (string, string?). Verified: - npm run check exits 0 (was 30+ errors). - npm run build succeeds. - npx vitest run: 10/10 tests pass. Unblocks #7.
drizzle-orm 0.39.3 with TypeScript 5.6.3 cannot reconcile the union of
pgTable + sqliteTable variants declared for the same logical tables in
shared/schema.ts. storage.ts operates on db whose type is the union of
node-postgres and better-sqlite3 adapters, and every .select/.insert/
.update/.delete call site fails with TS2349 ('no compatible signatures').

Codebase is unambiguously SQLite at runtime: dev.db is committed,
CI workflow doesn't set DATABASE_URL, better-sqlite3 is the actual driver.
docker-compose.yml mentions Postgres but storage.ts never wired against
pgTable types. Switch to sqlite-only:

- shared/schema.ts: drop pgTable imports and the *Sqlite duplicates;
  the canonical table exports (users, projects, ...) are now
  sqliteTable-backed with text/integer columns and datetime defaults.
- server/db.ts: drop the Postgres branch, always instantiate
  better-sqlite3 (filename honours DATABASE_URL when it doesn't look
  like a postgres URL, else 'dev.db').
- script/migrate.ts: SQLite-only.
- drizzle.config.ts: dialect fixed to 'sqlite'.
- server/test/setup.ts: drop pool from mock.
- server/storage.ts: convert new Date() assignments to ISO strings
  (text columns); default optional email to '' on insert.
- server/routes.ts: import Relationship/Action types, String() coerce
  req.params.id where express typings widened it to string | string[].
- server/index.ts: logger.error signature is (string, string?) — embed
  path/stack into the message instead of the second arg.

Verified:
- npm run check exits 0 from the lockfile (was 30+ errors).
- npm run build succeeds (client + server bundles).
- npx vitest run: 10/10 tests pass.
- Closes: Forgejo issue #9 (and unblocks #7).
Author
Owner

Closing this PR as part of repo flattening (parent kanban card t_74fbb28b).

The branch's fix is stale relative to main: main now carries commit 8bfee31 ("fix(#9): clear drizzle-orm schema overload errors blocking npm run check") which addresses the same issue with a different approach (narrowing the db type and adding logger meta). The branch's +39/-149 changes are largely already superseded by main.

Closing PR and deleting source branch fix/9-drizzle-overload. The work in this PR is preserved in git history on the branch's head SHA 8c0dc80.

Closing this PR as part of repo flattening (parent kanban card t_74fbb28b). The branch's fix is stale relative to main: `main` now carries commit 8bfee31 ("fix(#9): clear drizzle-orm schema overload errors blocking npm run check") which addresses the same issue with a different approach (narrowing the db type and adding logger meta). The branch's +39/-149 changes are largely already superseded by main. Closing PR and deleting source branch `fix/9-drizzle-overload`. The work in this PR is preserved in git history on the branch's head SHA 8c0dc80.
Mark closed this pull request 2026-09-21 01:16:59 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AuWoMe/Drift!11
No description provided.