Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,13 @@ Requires the `drizzle-orm` and `mysql2` peers. Reads run against a replica via r
| `insertIdOf` / `affectedRowsOf` / `insertedIdsOf` / `DzWriteResult` | Extract `insertId` / `affectedRows` (and derive contiguous bulk-insert ids) from a mysql2 write result. |
| `toJstDate` / `jstTimestampParams` / `jstDatetimeParams` / `jstDateParams` | JST date/time normalization params (advanced use). |
| `MYSQL_TIMEZONE` | Default mysql2 connection `timezone` (`'+09:00'`) for the JST DB deployment. |
| `jstTimestamp` / `jstDatetime` / `jstDate` / `decimalNumber` | Drizzle column helpers (no repo-side wrapper needed). |
| `jstTimestamp` / `jstDatetime` / `jstDate` | Drizzle column helpers (no repo-side wrapper needed). |
| `jstOnUpdateNow` | SQL expression for `ON UPDATE CURRENT_TIMESTAMP`. The `jstTimestamp` customType (and friends) do not support `.onUpdateNow()`, so pair it with `.$onUpdateFn(() => jstOnUpdateNow(fsp))`. |
| `coerceDecimalNumber` / `decimalNumberParams` | DECIMAL normalization params (the `decimalNumber` column helper is usually enough). |
| `DRIZZLE_ORM_OPTIONS` / `honoDrizzleConfig(options)` / `HonoDrizzleConfigOptions` | Shared Drizzle casing (`snake_case`) for both the runtime `drizzle()` call and `drizzle.config.ts`, keeping config ↔ runtime in sync. |
| `resolveDbSecret()` / `ResolvedDbSecret` | Resolve DB connection info from the `DB_SECRET` env var (an AWS RDS managed-secret JSON string) for CI migrate / local tooling. Returns `undefined` when `DB_SECRET` is unset; throws on invalid JSON or a missing required key. |
| `baselineMigrations(options)` / `readBaselineEntry(migrationsFolder)` / `BaselineMigrationsOptions` / `BaselineResult` / `BaselineEntry` | Brownfield first-deploy helper: mark an existing `0000_*` migration as applied without re-running DDL. |

#### Drizzle column helpers (`jstTimestamp` / `decimalNumber`, etc.)
#### Drizzle column helpers (`jstTimestamp` / `jstDatetime` / `jstDate`, etc.)

- `drizzle-orm` is a **peer** only. The kit does not include `drizzle-orm` as a dependency (even after publishing, it uses the consumer's single copy).
- The consumer just keeps `drizzle-orm` in its `dependencies` as usual. **No `overrides` in `package.json` are needed.**
Expand Down
9 changes: 1 addition & 8 deletions src/db/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* @remarks
* `drizzle-orm` is a **peer** (the consumer resolves a single copy); the kit does not bundle it. The
* return types are the `customType` inference as-is (`MySqlCustomColumnBuilder<…>`) with no `any`, so
* the column's semantic type (`string | Date`, `number | null`, etc.) propagates to the consumer
* table's `$inferSelect`.
* the column's semantic type (`string | Date`, etc.) propagates to the consumer table's `$inferSelect`.
*
* **Precondition (a single drizzle copy)**: Drizzle's `SQL` is a **nominal** type carrying a private
* field `shouldInlineParams`, so if the kit and the consumer resolve different copies of drizzle,
Expand All @@ -23,8 +22,6 @@
*/
import { sql } from 'drizzle-orm';
import { customType } from 'drizzle-orm/mysql-core';
import { decimalNumberParams } from './decimal.js';
import type { DecimalNumberConfig } from './decimal.js';
import { jstDateParams, jstDatetimeParams, jstTimestampParams } from './jst.js';

/**
Expand All @@ -47,7 +44,3 @@ export const jstDatetime = (name: string, opts?: { fsp?: number }) =>
/** MySQL `date` — on INSERT/UPDATE, normalizes ISO / empty strings to `YYYY-MM-DD` (via `toDriver`). */
export const jstDate = (name: string) =>
customType<{ data: string | null; driverData: string | null }>(jstDateParams())(name);

/** MySQL `decimal` — SELECT coerces string→number via `fromDriver`; writes bind the number as-is. */
export const decimalNumber = (name: string, config: DecimalNumberConfig) =>
customType<{ data: number | null; driverData: number | string | null }>(decimalNumberParams(config))(name);
37 changes: 0 additions & 37 deletions src/db/decimal.spec.ts

This file was deleted.

71 changes: 0 additions & 71 deletions src/db/decimal.ts

This file was deleted.

5 changes: 1 addition & 4 deletions src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ export type { HyperdriveLike, ExecutionContextLike } from './connection.js';

export { MYSQL_TIMEZONE, toJstDate, jstTimestampParams, jstDatetimeParams, jstDateParams } from './jst.js';

export { coerceDecimalNumber, decimalNumberParams } from './decimal.js';
export type { DecimalNumberConfig } from './decimal.js';

export { jstTimestamp, jstDatetime, jstDate, decimalNumber, jstOnUpdateNow } from './columns.js';
export { jstTimestamp, jstDatetime, jstDate, jstOnUpdateNow } from './columns.js';

export { DRIZZLE_ORM_OPTIONS, honoDrizzleConfig, resolveDbSecret } from './orm-config.js';
export type { HonoDrizzleConfigOptions, ResolvedDbSecret } from './orm-config.js';
Expand Down
Loading