Skip to content

[Proposal] Migration "definition" files should be synthetic #4539

Closed

Description

@craiglabenz

Problem to Solve

Migrations are tricky, especially if two developers are working on different ones concurrently and land them out of order. Consider Branch A and Branch B, both of which add a migration. If Branch B lands first, Branch A's definition files now lack knowledge of Branch B's migration's changes.

Branch A is now faced with difficult resolution options or leaving incomplete and misleading "definition" files in the codebase.

Proposal

Database schema "definition" files should be generated on the fly whenever the system needs them and should not be source controlled artifacts.

Because the serverpod create-migration command can produce these definition files in (what seems to be) several hundred milliseconds, their generation could probably be deferred until such time as they are read.

Use Case

See the Branch A and Branch B scenario above.

Alternatives

The primary alternative would be to leave the system how it is.

Additional context

❤️

How experienced are you with this library?

Intermediate - Familiar with the basics or have used it in a few projects

Are you interested in working on a PR for this?

  • I want to work on this

Activity

  1. added
    enhancement
    on Jan 6, 2026
  2. t-kietzmann commented on Jan 7, 2026

    @t-kietzmann

    We are not pushing any migrations to GitHub. Every dev has its own local migrations.

    We have something like a "deploy branch" in our pipeline which has its own migrations then. Maybe this approach helps.

  3. craiglabenz commented on Jan 7, 2026

    @craiglabenz
    ContributorAuthor

    @t-kietzmann Does this mean every developer runs the create-migration command as needed after a git pull introduces a different branch's new models? That seems like a reasonable workaround, but also I think suggests that these definition files should always be generated on-demand. If they were, I imagine you wouldn't feel a need to do that.

  4. craiglabenz commented on Jan 7, 2026

    @craiglabenz
    ContributorAuthor

    Closing as dupe of #4503.

  5. moved this from Inbox 📫 to Done 🚀 in Serverpod Frameworkson Jan 7, 2026
  6. t-kietzmann commented on Jan 7, 2026

    @t-kietzmann

    @craiglabenz I'd like to quickly answer your question: yes, that's exactly how we do it. We had many problems/conflicts in the beginning (a very long time ago) when several developers worked on the same project (and modules), but since we've been doing it this way, everything runs smoothly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions