Repository navigation
Conversation
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.
When a Rust app shares its database with an existing app that already has a
migrationstable (for example, an app moving from PHP Laravel to Laravel Rust that keeps its database), the two apps can't keep separate migration histories. laravel-rust hardcodes the table name:crates/database/src/db/migrations.rs#L189, L198, L222, L253, L303crates/database/src/db/migrations/schema_dump.rs#L132, L147, L171, L234PHP Laravel lets you rename it in
config/database.php:Since Laravel 11 this has no env variable, and the migrator,
migrate:statusand the schema dump all read it.Repro
# The database already has another app's `migrations` table. laravel migrateRust adds its rows to the other app's
migrationstable,migrate:statuslists the other app's migrations as "ran, not registered", andschema:dumpdumps the other app's rows.Fix
Database::migrations_table, which defaults to"migrations". Like Laravel, it isn't read from the environment. You set it insrc/config/database.rs:DatabaseManagergives the name to every connection it registers. Somigrate,migrate:fresh,migrate:status,schema:dump(pg_dump-t, mysqldump, sqlite3.dump), loading a schema dump, andrefresh_databasetest databases all use it. Nothing else needed changing.StartupError::Migrations. Schema-qualified names are rejected because the dump clients can't target them consistently.docs/migrations.md.This doesn't overlap #412 (which changes shadow-table filtering in
dump_sqlite) or #457 (which changesmake:migrationtimestamps).Tests
tests/migrations.rs: withmigrations_table = "rust_migrations",migraterecords intorust_migrations, leaves a pre-existingmigrationstable and its row alone, andmigrate:statusdoesn't list the other app's migration. An invalid or schema-qualified name stops startup.tests/schema_dump.rs:schema:dumpwrites therust_migrationsrows, andmigrate:freshloads the dump back with nomigrationstable created.cargo test --all-features --test database -- --include-ignored migrations:: schema_dump::against local PostgreSQL 18 and MySQL 8.0: 30 passed. This covers the PostgreSQL$1, $2insert path and the existing pg_dump/mysqldump round trips.cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo fmt --all -- --check,cargo check --no-default-features --all-targetsand the core/database lib tests all pass.Created with Claude Opus 5.5 in Claude Code.