Allow layout-altering automigrations of event tables#5269
Merged
Conversation
This commit adds special handling in automigrations to accept a broad set of schema- and layout-altering automigrations on event tables, including changes that we'd reject for non-event tables like removing or reordering columns, or layout-incompatibly changing the types of existing columns. This is due to a change we want to make to the ControlDB schema, where we have a product type which is used both as a table type, and as the column type of an event table, and we want to add an element to that product type. I've added a simple smoketest of the new behavior, `automigrate_reschema_event_table_arbitrarily`. Note that I have not tested commitlog replay of a database which has undergone one of these migrations, which has been a common place that bugs have appeared in similar changes in the past. I have done a pretty lazy job with the migration plan formatter for the new step, just printing the name of the event table which is changing, not any information about the specific changes or the columns. This is in an effort to save time, as we'd like to release the ControlDB change blocked by this.
joshua-spacetime
left a comment
Contributor
There was a problem hiding this comment.
Can we add a commitlog replay test for this? In particular replay from snapshot?
Contributor
Author
I am not sure how we would do that. To my knowledge, we don't currently have any tests of commitlog replay, or any infrastructure for testing it. |
Tested manually by doing the same automigrations as in the smoketest, then restarting the database and calling a procedure in the migrated database to force replay.
…klabs/SpacetimeDB into phoebe/automigrate-event-tables
Contributor
Author
|
I have not added an automated test of replay, but I tested it manually, and it worked after my latest commit. |
joshua-spacetime
approved these changes
Jun 11, 2026
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.
Description of Changes
This commit adds special handling in automigrations to accept a broad set of schema- and layout-altering automigrations on event tables, including changes that we'd reject for non-event tables like removing or reordering columns, or layout-incompatibly changing the types of existing columns.
This is due to a change we want to make to the ControlDB schema, where we have a product type which is used both as a table type, and as the column type of an event table, and we want to add an element to that product type.
I've added a simple smoketest of the new behavior,
automigrate_reschema_event_table_arbitrarily. Note that I have not tested commitlog replay of a database which has undergone one of these migrations, which has been a common place that bugs have appeared in similar changes in the past.I have done a pretty lazy job with the migration plan formatter for the new step, just printing the name of the event table which is changing, not any information about the specific changes or the columns. This is in an effort to save time, as we'd like to release the ControlDB change blocked by this.
API and ABI breaking changes
N/a
Expected complexity level and risk
3 at least: new categories of automigrations have a high risk to introduce commitlog replay bugs, and it's also possible I have misunderstood or mis-remembered some of the safety invariants of the
tablecrate.Testing
return_valuein the migrated module to force commitlog replay.