twenty icon indicating copy to clipboard operation
twenty copied to clipboard

Refactor migration runner within transaction

Open Weiko opened this issue 5 months ago • 2 comments

Modifying the data-model can sometimes fail in the middle of your operation, due to the way we handle both metadata update and schema migration separately, a field can be created while the associated column creation failed (same for object/table and such). This is also an issue because WorkspaceMigrations are then stored as FAILED can never really recovered by themselves so the schema is broken and we can't update the models anymore. This PR adds a executeMigrationFromPendingMigrationsWithinTransaction method where we can (and must) pass a queryRunner executing a transaction, which should come from the metadata services so that if anything during metadata update OR schema update fails, it rolls back everything (this also mean a workspaceMigration should never stay in a failed state now). This also fixes some issues with migration not running in the correct order due to having the same timestamp and having to do some weird logic to fix that.

This is a first step and fix before working on a much more reliable solution in the upcoming weeks where we will refactor the way we interact with the data model.

Weiko avatar Jun 28 '25 15:06 Weiko

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:28201

This environment will automatically shut down when the PR is closed or after 5 hours.

github-actions[bot] avatar Jun 28 '25 16:06 github-actions[bot]

(this also mean a workspaceMigration should never stay in a failed state now).

This means it will stay as no applied yet ?

prastoin avatar Jul 02 '25 08:07 prastoin

(this also mean a workspaceMigration should never stay in a failed state now).

This means it will stay as no applied yet ?

it won't even be stored in the DB

Weiko avatar Jul 02 '25 13:07 Weiko

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎

sentry[bot] avatar Jul 04 '25 12:07 sentry[bot]

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎

Impossible this hasn't been released in production yet, this will fix the issue

prastoin avatar Jul 04 '25 13:07 prastoin