Read-only migration status queries (skip CREATE TABLE)#3144
Merged
Conversation
Add `get_pending_migrations_read_only`, `get_applied_migrations_read_only`, and `get_migration_with_status_read_only` to both `MigratorTrait` and `MigratorTraitSelf`. They mirror the existing query methods but never run `CREATE TABLE`, so a database user without DDL privileges can check migration status. A missing migration table reports all migrations as pending. Purely additive; existing methods are unchanged. Closes #3141
The test connects to sqlite::memory:, but the MySQL/Postgres CI jobs run the migrator tests with only their own backend feature (no sqlite driver), so the test failed there. Gate the whole file on the sqlx-sqlite feature.
Replace the sqlite-only read_only test with a run_read_only_test in the migrator integration suite, which runs against SQLite, MySQL, and Postgres via DATABASE_URL. Verifies status queries report pending without creating the table, work once it exists, and reflect applied migrations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
get_pending_migrations_read_only/get_applied_migrations_read_only/get_migration_with_status_read_only(on both migrator traits) that query migration status without runningCREATE TABLE, so a DB user without DDL privileges can check for pending migrations. A missing migration table reports all as pending. Purely additive.Closes #3141