Skip to content

Decouple --plan from destructive migrate to prevent any accidental changes #163

Description

@ankitsmt211

Code of Conduct

  • I agree to follow Django's Code of Conduct

Feature Description

Introduce a dedicated, read-only migrationplan command to prevent accidental database execution, providing a safe alternative to the high-risk migrate --plan flag.

Problem

When migrating changes, we often find ourselves executing these two commands directly on the server or locally.

python manage.py migrate --plan  #show me what's planned

If the output is clean and expected, we commit the changes using

python manage.py migrate  #yep execute this plan

First command is ready-only which displays what's django will commit to database if we went ahead with migrate command whereas migrate is a destructive command that will make changes to your schema if ran successfully.

For destructive commands it's generally a better UX to be more explicit, so when you're running the --plan (you're almost close to writing migrate version since it's a superset of that command). If accidentally ran, it can be painful/frustrating experience.

Request or proposal

proposal

Additional Details

--plan can be later deprecated if required

Note: Also this pattern can be called out for other flags on migrate command, that's something worth discussing.

Implementation Suggestions

Open to suggestions but this can be a good candidate

python manage.py migrationplan

can be used to do what

python manage.py migrate --plan

separating both migrate and migrate --plan

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions