Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration is completed but the history recording failed. #284

Open
Tigrov opened this issue Feb 2, 2025 · 3 comments
Open

Migration is completed but the history recording failed. #284

Tigrov opened this issue Feb 2, 2025 · 3 comments

Comments

@Tigrov
Copy link
Member

Tigrov commented Feb 2, 2025

There are cases when the migration was successful, but writing the history record was failed.

After this, the migration can be rolled back or corrected manually only, since there is no the history record.

Possible solution for a transactional migration run the migration and add the history record in the one transaction.

true => $this->db->transaction(fn () => $migration->up($this->createBuilder())),

$this->addMigrationToHistory($migration);

@vjik
Copy link
Member

vjik commented Feb 2, 2025

It's real case? Under what conditions did this happen?

@Tigrov
Copy link
Member Author

Tigrov commented Feb 3, 2025

During migration the table prefix was changed using $db->setTablePrefix(), after the migration was completed the prefix_migration history table was not exist.

Actually this is a configuration problem (set migration table without prefix) or a code problem ($db->setTablePrefix()).
But after fixing it I cannot re-run the migration and need to add a record to migration table manually.

@samdark
Copy link
Member

samdark commented Feb 3, 2025

Note that MySQL doesn't support transactions for schema changes.

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

No branches or pull requests

3 participants