fix: structured config with create_if_missing for non-existent database#51
Conversation
There was a problem hiding this comment.
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.
b278269 to
1f8fef6
Compare
There was a problem hiding this comment.
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_databaseto structured DB config to control which DB is used for bootstrap duringcreate_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>
1f8fef6 to
5676cdf
Compare
Summary
create_if_missing: truewhen 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.create_if_missingphase targets the same database as the structured configname, initium now connects to the driver's default admin database (postgres/mysql) first, creates the target, then reconnects.optionsfield, and thecreate_if_missingregression for both PostgreSQL and MySQL.Test plan
cargo clippy,cargo fmt,dprint checkcleandocker 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