Skip to content

docs: read the sample and quickstart schema from migrations - #47

Merged
omer-cengel merged 2 commits into
masterfrom
chore/sample-and-quickstart-migration-directory
Sep 27, 2026
Merged

omer-cengel merged 2 commits into
masterfrom
chore/sample-and-quickstart-migration-directory

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

The external Maven sample and the quickstart now point sql[].schema at a Flyway-style sql/migrations directory instead of a single schema snapshot. This shows sqlcj reading the schema an application already maintains through migrations. The later migration adds a column and an index, and the generated repository and the sample's output stay the same.

Changes

  • Replace the sample's sql/schema.sql with V1__create_authors_and_books.sql, which creates authors (id, name, bio) and books, and V2__add_author_created_at_and_book_index.sql, which adds authors.created_at and creates an index on books (author_id).
  • Set the sample's sqlcj.yaml to schema: sql/migrations and update the App Javadoc to describe the migrations being applied in version order.
  • Make the release verification script generate from the migration directory, check that the generated row carries LocalDateTime createdAt, and apply both migrations with psql in version order under ON_ERROR_STOP before running the sample.
  • Update the quickstart's project layout, configuration, schema section and database setup to use the two migration files. The schema section explains Flyway version ordering, how ALTER TABLE ... ADD COLUMN applies to the table created earlier, and why CREATE INDEX is accepted and ignored.

Scope and non-goals

  • No compiler or runtime behavior changes. sqlcj still reads migration files and never executes them.
  • No migration tool is added. The sample and the quickstart apply migrations with psql.
  • The generated API, selected-column order, sample queries and sample runtime output are unchanged.

The sample's sqlcj.yaml names sql/migrations instead of a schema snapshot.
V1 creates authors and books, and V2 adds authors.created_at and an index
on books (author_id). The release script generates from the directory,
checks that the generated row carries the added column, and applies both
migrations with psql in version order before running the sample.
@omer-cengel
omer-cengel merged commit 2652c19 into master Sep 27, 2026
6 checks passed
@omer-cengel
omer-cengel deleted the chore/sample-and-quickstart-migration-directory branch September 27, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant