Skip to content

Support renaming a field in a table model, i.e. renaming a DB column #4602

Closed as duplicate

Description

@christerswahn

Problem to Solve

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:

  instanceId: String?, altered_from(name: resourceId)

(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

  1. Complex multi-deploy approach to migrate from one column name to another
  2. 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

Are you interested in working on a PR for this?

  • I want to work on this

Activity

  1. 89pleasure commented on Jan 22, 2026

    @89pleasure
  2. marcelomendoncasoares commented on Jan 22, 2026

    @marcelomendoncasoares
    Collaborator

    @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.

  3. added
    in triageIssues under investigation before priority assignment. Can be closed if pending info for too long.
    on Jan 22, 2026
  4. moved this from Inbox 📫 to In Progress 🔥 in Serverpod Frameworkson Jan 29, 2026
  5. removed
    in triageIssues under investigation before priority assignment. Can be closed if pending info for too long.
    on Jan 29, 2026
  6. marcelomendoncasoares commented on Apr 7, 2026

    @marcelomendoncasoares
    Collaborator

    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.

  7. moved this from In Progress 🔥 to Done 🚀 in Serverpod Frameworkson Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area: databaseIssues related to the database.enhancementNew feature or requeststake: cloudIssues that are prioritized for Serverpod Cloud.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions