durcno@1.0.0-alpha.12
Major Changes
-
f680e01 - Thanks to @almahdi404 !
change!: auto-convert schema identifiers from camelCase to snake_case
Durcno now automatically converts all schema identifiers from camelCase to snake_case when generating SQL and migration files. You can write your entire schema in TypeScript-idiomatic camelCase — Durcno handles the PostgreSQL side.
This affects every identifier passed to a schema builder:
Builder Identifiers converted table(schema, name, ...)schema, table name, column names enumtype(schema, name, ...)schema, enum name sequence(schema, name, ...)schema, sequence name Enum values are not converted — they remain exactly as written.
export const BlogPosts = table("public", "blogPosts", {id: pk(),authorId: bigint({ notNull }),publishedAt: timestamp({ notNull }),});Generates:
CREATE TABLE "public"."blog_posts" ("id" bigserial PRIMARY KEY,"author_id" bigint NOT NULL,"published_at" timestamp NOT NULL);Breaking changes:
- Any existing schema using camelCase identifiers that relied on the raw (unconverted) name being used in SQL or migrations will now produce snake_case identifiers instead. Re-generate your migrations after upgrading.
- Constraint name helpers (
check(),primaryKey(),unique()) no longer auto-prefix or auto-suffix names. The name you provide is used exactly as-is. Previously,primaryKeyanduniquewould prepend the table name if it wasn't already present, andcheckwould append_checkif missing. You must now supply the full constraint name yourself. The recommended conventions are:- Primary key:
pk_<table> - Unique:
unique_<table>_<col>[_and_<col>]* - Check:
check_<table>_<col>[_and_<col>]*[_<suffix>]?
- Primary key:
-
7bf19a8 - Thanks to @almahdi404 !
change(columns)!: introduce and helpers for array dimensions
The
dimensionoption on column configs now requires aDimensionobject instead of a raw tuple literal. Two helper functions are exported fromdurcnoto construct these objects:array()— creates a variable-length (unbounded) dimension, equivalent totype[]tuple(size)— creates a fixed-length dimension ofsizeelements, equivalent totype[N]
Both helpers return a
Dimensioninstance that exposes.array()and.tuple(size)methods for chaining multi-dimensional shapes.// Before (no longer valid)tags: varchar({ length: 50, dimension: [null] as const });coordinates: integer({ dimension: [3] as const });matrix: integer({ dimension: [null, null] as const });// Aftertags: varchar({ length: 50, dimension: array() });coordinates: integer({ dimension: tuple(3) });matrix: integer({ dimension: array().array() });vectors: integer({ dimension: tuple(2).array() });Breaking change: the
dimensionproperty type changed fromReadonly<[number | null, ...(number | null)[]]>toDimension<readonly (number | null)[]>. Raw tuple literals are no longer accepted.
Minor Changes
-
eda5522 - Thanks to @almahdi404 !
feat(cli/squash): validate db state and sync tracking records
The
squashcommand now connects to the database to validate migration state and keep thedurcno.migrationstracking table consistent after a squash.Mixed-state validation: if the squash range contains a mix of applied and unapplied migrations, the command exits with an error listing which are in each bucket.
Tracking sync: when all migrations in the range are applied, the individual tracking records are deleted and replaced with a single entry pointing to the squashed migration's start name.
--skip-dbflag: pass--skip-dbto bypass all database interaction entirely — useful in environments where the database is unavailable.# Normal usage — connects to DB for validation and tracking syncdurcno squash 2024-01-01T00-00-00.000Z 2024-06-01T00-00-00.000Z# Skip DB — no validation, no tracking updatedurcno squash 2024-01-01T00-00-00.000Z 2024-06-01T00-00-00.000Z --skip-db
Patch Changes
-
0425ef9 - Thanks to @almahdi404 !
perf: use columnsBySql index for faster column lookups
Replace repeated
snakeToCamelstring conversions with a pre-builtcolumnsBySqlindex keyed by SQL column names. This optimization eliminates runtime string transformations during result row conversion in query builders (Select, Insert, InsertReturning, FirstQuery, Update).The
Tableconfiguration now includes acolumnsBySqlobject that maps SQL column names directly to column definitions, enabling O(1) lookups instead of string conversion followed by object lookup. This reduces CPU overhead on every row returned from the database.