PHP - Database schema: version control, branching, migrations

前端 未结 1 1189
一生所求
一生所求 2021-02-19 17:33

I\'m trying to come up with (or find) a reusable system for database schema versioning in php projects.

There are a number of Rails-style migration projects available fo

相关标签:
1条回答
  • 2021-02-19 18:26

    Well, I wasn't able to find any reason not to move forward.

    The project, such as it is, is here:

    http://github.com/Billiam/MySQL-PHP-AutoMigrations

    Needs some love (accurate comments, unit testing, actual bug testing), but seems to be working well for me now.

    It's a fork of http://code.google.com/p/mysql-php-migrations/ to include the ideas above, and some other little stuff.

    Migrating down is done from methods saved in the database on the way up so that file changes (like those when switching between branches) do not affect downward migrations. Added two functions:

    • a magic 'auto' function that handles migrating down to the oldest shared migration, and then up to the newest migration in the migrations directory.
    • 'propose' function that shows what auto will actually do.

    Still very open to hearing potential (or even expected) pitfalls from this approach however.

    0 讨论(0)
提交回复
热议问题