Skip to content

v1.0.2 — meta migrate writes type changes Postgres can apply; generated JVM types are buildable from Java (coordinated PATCH)

Choose a tag to compare

@dmealing dmealing released this 11 Sep 11:49
· 184 commits to main since this release

npm 1.0.2 · Maven Central 8.0.2 · PyPI 1.0.1 and NuGet 1.0.1 sit this one out (no Python or C# product file changed) · metamodelVersion stays 1.0.

meta migrate now writes a column type change Postgres can apply

This changes what meta migrate emits against an existing database. A change between two kinds with no assignment cast between them was emitted as a bare ALTER COLUMN … TYPE, which Postgres refuses ("cannot be cast automatically") in the up and the down alike. That covered jsonb → text[] and back, a plain string moved to isArray, boolean → integer, and text → jsonb. A column with a DEFAULT was refused even where its data could convert. The most exposed path is the one the authoring skill's jsonb ladder calls the only rung that migrates a column: field.string + @dbColumnType: jsonb moved to isArray: true. The migration was written, and nothing could apply it.

Each type change now carries its conversion:

  • jsonb → array goes through a helper function created in the table's schema and dropped at the end. It keeps element order and fails loudly on a row that is not an array.
  • array → jsonb goes through to_jsonb.
  • A scalar moved to an array becomes the array's one element. Removing isArray narrows the column, and fails on a row holding more than one element.
  • A DEFAULT in the way is dropped before the conversion and set after.

A change blocked by an auto-sequence default now names --allow drop-identity-default. Every case is exercised against a live Postgres through applyPending and rollbackTo.

Generated JVM types are constructible from Java

  • Kotlin (codegen-kotlin): a generated entity or value object gains a nested Builder and a @JvmStatic builder() (#365). Java callers previously had only the N-arg constructor.
  • Java (codegen-spring): a generated record gains the same kind of builder. That covers an entity's <Name>Dto, an object.value, and a prompt's payload and response records. A projection's read DTO gets none, since it arrives from a query.

Authoring skill: the jsonb ladder

Bundled in @metaobjectsdev/sdk. It had four gaps:

  • It still called the #362 gap open, though 1.0.1 closed it.
  • Its vectorScores example sat on the wrong rung.
  • It did not explain how a value object reaches a Java consumer.
  • It never said the isArray rung is a migration that needs --allow type-change.

Full detail: CHANGELOG.md.