Skip to content

Immutable database migrations #107

@Jord-JD

Description

@Jord-JD

What you would like to change/add

Laravel documentation defines database migrations as follows.

Migrations are like version control for your database

Just as we do not modify git commit history, I would like to propose we officially adopt the best practice of not modifying existing database migrations once they are in a mainline branch.

A mainline branch is defined here as master, staging or production.

Why you would like to change/add this

Just as we do with our code repositories, version controlled systems should not have their histories modified apart from in exceptional circumstances. Therefore, once a PR is accepted into a mainline branch that others will be using, we should avoid making modifications to existing migrations and inconveniencing our fellow developers.

There is no harm is having a larger number of migration files. In fact, it can be useful to see the evolutionary of a tables structure to see why and when certain fields were added/removed/changed in associated with related feature development.

Concerns over this change meaning database migration files can not be used as a reference for table structure makes sense, but are not in keeping with how migrations should be used. Table structure should always be referenced from within a database schema browser.

Checklist

  • I have checked that this is not a duplicate issue.

Sources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions