Skip to content

Apply DB migration via the serverpod CLI command #3119

Closed

Description

@christerswahn

Problem to Solve

Today DB migrations are applied using the server runtime. But DB migrations are often better to run as a deployment step that is handled separately from actual server start.

Proposal

Refactor the apply migrations logic in Serverpod server for reusability from the serverpod command, and add support for running it there.

(Issue #3118 is not strictly a prerequisite but would make using this command easier.)

Use Case

As a user, I'd like to be able to run it as an operation that stands alone from the server, via the serverpod CLI command.

Alternatives

An alternative could be to add a distinct subcommand to Serverpod server that effectively corresponds to the command line:

$ dart run bin/main.dart --role maintenance --apply-migrations

Additional context

Related to #3120

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. added
    area: database
    area: deployment
    enhancement
    on Jan 13, 2025
  2. added
    area: cli
    on Jan 13, 2025
  3. removed
    area: database
    area: deployment
    on Jan 14, 2025
  4. KristijanZic commented on Jan 16, 2025

    @KristijanZic
    Contributor

    Could you elaborate more?
    It seems to me that every time you apply migration you also need to deploy the new server app anyway so you might as well apply migrations when the new server is deployed and launched like it works now.

    By separating the two you'd need to manually do 2 steps instead of one and if one fails you'd have a database with incompatible server or a server with incompatible database.

    Could you expand a bit?

  5. moved this from Next 🌟 to Later 🥳 in Serverpod Frameworkson Jun 24, 2025
  6. moved this from Later 🥳 to Backlog 🗂️ in Serverpod Frameworkson Jun 24, 2025
  7. moved this from Backlog 🗂️ to Done 🚀 in Serverpod Frameworkson May 4, 2026
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

    area: clienhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions