You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support renaming a field in a table model, i.e. renaming a DB column #4602
As the development of a server codebase evolves, it often happens that fields are renamed to better reflect their intent and content. However for fields defined in Serverpod table models this is not possible for a live service without a cumbersome multi-deploy and migration approach (create the new field, migrate the data from the old field and ensure all code updates both old and new the same way, then delete the old field).
Proposal
If the previous field definition in the .spy.yaml file was:
resourceId: String?
The renaming could perhaps be expressed like this:
(The reason for calling it altered_from and using a named parameter name: is that perhaps we would want to support changing the type as well in the future, e.g. like altered_from(type: String).)
Use Case
As a user, I should be able to do simple updates to my database schema so that they are also simple to do in Serverpod.
Alternatives
Complex multi-deploy approach to migrate from one column name to another
Hack the Serverpod DB migration scripts manually, and probably needing to circumvent CI checks since the model code will mismatch either the old or the new naming (and this is not possible with a multi-instance server).
Additional context
No response
How experienced are you with this library?
Expert - Experienced and comfortable with using this library in complex projects
@89pleasure Your suggestion is right in terms of the syntax, but the migration system has not been updated to generate the appropriate RENAME statement. We need to add this detection so that columns are properly renamed instead of dropped/added as it is now. I'll create a separate issue for this and link here.
Activity
89pleasure commentedon Jan 22, 2026
This should be solved with the new (experimental) feature of column name overrides:
https://docs.serverpod.dev/concepts/experimental#column-name-override
marcelomendoncasoares commentedon Jan 22, 2026
@89pleasure Your suggestion is right in terms of the syntax, but the migration system has not been updated to generate the appropriate
RENAMEstatement. We need to add this detection so that columns are properly renamed instead of dropped/added as it is now. I'll create a separate issue for this and link here.marcelomendoncasoares commentedon Apr 7, 2026
Since this will be fixed with #4635, I'll close it as duplicate, since the other issue has a more detailed explanation on how to implement.