How do you maintain revision control of your database structure?

前端 未结 5 1717
栀梦
栀梦 2021-01-16 14:12

What is the simplest way of keeping track of changes to a projects database structure?

When I change something about the database (eg, add a new table, add a new fie

5条回答
  •  独厮守ぢ
    2021-01-16 14:43

    This has alrady been discussed a lot I think. Anyhow I really like Rails approach to the issue. It's code that has three things:

    1. The version number
    2. The way of applying the changes (updates a version table)
    3. The way of rolling the changes back (sets the version on the version table to the previous)

    So, each time you make a changeset you create this code file that can rollback or upgrade the database schema when you execute it.

    This, being code, you can commit in any revision control system. You commit the first dump and then the scripts only.

    The great thing about this approach is that you can easily distribute the database changes to customers, whereas with a standard just dump the schema and update it approach generating an upgrade/rollback script is a nuisance

提交回复
热议问题