Skip to content

Conversation

@albertlai431
Copy link
Contributor

What ❔

zkstack dev migrate attempts to create a database first before performing the migration. It should instead only try to perform the migration, and fail if the database does not exist.

Why ❔

Keeping the create database command may potentially drop and recreate the database - the current behaviour of cargo sqlx database create doesn't do this, but it may change in the future. Furthermore, even if the database doesn't exist, it doesn't make sense for a migrate command to perform database creation.

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zkstack dev fmt and zkstack dev lint.

@albertlai431 albertlai431 changed the title fix: shouldn't attempt to create db on migrate command fix(zkstack): shouldn't attempt to create db on migrate command Jan 14, 2025
@sanekmelnikov sanekmelnikov self-requested a review January 14, 2025 17:06
@sanekmelnikov sanekmelnikov added this pull request to the merge queue Jan 14, 2025
Merged via the queue into matter-labs:main with commit c156e79 Jan 14, 2025
33 checks passed
zkzoomer pushed a commit that referenced this pull request Jun 21, 2025
## What ❔
`zkstack dev migrate` attempts to create a database first before
performing the migration. It should instead only try to perform the
migration, and fail if the database does not exist.

## Why ❔
Keeping the create database command may potentially drop and recreate
the database - the current behaviour of `cargo sqlx database create`
doesn't do this, but it may change in the future. Furthermore, even if
the database doesn't exist, it doesn't make sense for a migrate command
to perform database creation.

## Checklist
- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev
lint`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants