Skip to content

fix: structured config with create_if_missing for non-existent database#51

Merged
mikkeldamsgaard merged 1 commit intomainfrom
fix/50-structured-config-create-if-missing
Mar 14, 2026
Merged

fix: structured config with create_if_missing for non-existent database#51
mikkeldamsgaard merged 1 commit intomainfrom
fix/50-structured-config-create-if-missing

Conversation

@mikkeldamsgaard
Copy link
Contributor

Summary

  • Fixes structured database config failing with create_if_missing: true when the target database does not yet exist (regression from URL-based config). Closes seed: structured database config fails with create_if_missing when target database does not exist (regression from 1.2.0) #50.
  • When a create_if_missing phase targets the same database as the structured config name, initium now connects to the driver's default admin database (postgres / mysql) first, creates the target, then reconnects.
  • Adds integration tests for structured config edge cases: special-character passwords (URL-reserved chars), PostgreSQL options field, and the create_if_missing regression for both PostgreSQL and MySQL.

Test plan

  • All 25 integration tests pass (including 5 new ones)
  • All 173 unit tests pass
  • cargo clippy, cargo fmt, dprint check clean
  • CI passes
docker compose -f tests/docker-compose.yml up -d --wait
INTEGRATION=1 cargo test --test integration_test -- --test-threads=1
docker compose -f tests/docker-compose.yml down

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 14, 2026 14:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression in seed when using structured database config with a create_if_missing: true phase targeting the same database as database.name, ensuring initium can create the DB before the initial connection would otherwise fail.

Changes:

  • Add a bootstrap connection path for structured configs to create a missing target database before reconnecting to the configured database.
  • Add new integration tests covering structured config edge cases (special-character passwords, Postgres options, and the create-if-missing regression for Postgres/MySQL).
  • Document the fix and new integration tests in the changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/seed/mod.rs Adds bootstrap logic to connect to an admin/default database for initial create_if_missing database creation, then reconnects.
tests/integration_test.rs Adds integration tests for structured-config connection edge cases and the regression scenario from #50.
CHANGELOG.md Notes the regression fix and new integration tests under Unreleased.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression in initium seed where structured DB configs failed when create_if_missing: true targeted the same (non-existent) database as database.name, by adding a bootstrap connection path and documenting/testing the behavior.

Changes:

  • Add database.default_database to structured DB config to control which DB is used for bootstrap during create_if_missing.
  • Add bootstrap connection flow in seeding to create the target DB before reconnecting to it.
  • Add integration tests covering structured config edge cases (special-character passwords, Postgres options, and the create-if-missing regression) plus schema/docs/changelog updates.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/seed/mod.rs Adds bootstrap connection logic for structured configs when create_if_missing targets database.name.
src/seed/schema.rs Extends structured DB config with default_database and adds parsing tests.
tests/integration_test.rs Adds integration coverage for structured config edge cases and the create-if-missing regression for Postgres/MySQL.
docs/seeding.md Documents database.default_database and updates the schema reference table.
CHANGELOG.md Records the new config field, bug fix, and added integration coverage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…se (#50)

When using structured database config, the `name` field was included in
the initial connection string. If the target database did not exist yet
(and a phase had `create_if_missing: true`), the connection failed before
the create phase could run.

Now initium detects this scenario and first connects to a bootstrap
database (`postgres` by default for PostgreSQL, no database for MySQL),
creates the missing database, then reconnects to the target for full
execution.

Adds `database.default_database` config field to override the bootstrap
database for environments where the default is not accessible.

Also adds integration tests for structured config edge cases:
special-character passwords, PostgreSQL options field, custom
default_database, and the create_if_missing regression.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mikkeldamsgaard mikkeldamsgaard force-pushed the fix/50-structured-config-create-if-missing branch from 1f8fef6 to 5676cdf Compare March 14, 2026 15:09
@mikkeldamsgaard mikkeldamsgaard merged commit 316397c into main Mar 14, 2026
7 checks passed
@mikkeldamsgaard mikkeldamsgaard deleted the fix/50-structured-config-create-if-missing branch March 14, 2026 15:11
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.

seed: structured database config fails with create_if_missing when target database does not exist (regression from 1.2.0)

2 participants