Is there a version control system for database structure changes?

后端 未结 22 1172
梦毁少年i
梦毁少年i 2020-11-30 17:53

I often run into the following problem.

I work on some changes to a project that require new tables or columns in the database. I make the database modifications and

相关标签:
22条回答
  • 2020-11-30 18:14

    There's a PHP5 "database migration framework" called Ruckusing. I haven't used it, but the examples show the idea, if you use the language to create the database as and when needed, you only have to track source files.

    0 讨论(0)
  • 2020-11-30 18:15

    If you're using SQL Server it would be hard to beat Data Dude (aka the Database Edition of Visual Studio). Once you get the hang of it, doing a schema compare between your source controlled version of the database and the version in production is a breeze. And with a click you can generate your diff DDL.

    There's an instructional video on MSDN that's very helpful.

    I know about DBMS_METADATA and Toad, but if someone could come up with a Data Dude for Oracle then life would be really sweet.

    0 讨论(0)
  • 2020-11-30 18:17

    Redgate has a product called SQL Source Control. It integrates with TFS, SVN, SourceGear Vault, Vault Pro, Mercurial, Perforce, and Git.

    0 讨论(0)
  • 2020-11-30 18:17

    Take a look at the oracle package DBMS_METADATA.

    In particular, the following methods are particularly useful:

    • DBMS_METADATA.GET_DDL
    • DBMS_METADATA.SET_TRANSFORM_PARAM
    • DBMS_METADATA.GET_GRANTED_DDL

    Once you are familiar with how they work (pretty self explanatory) you can write a simple script to dump the results of those methods into text files that can be put under source control. Good luck!

    Not sure if there is something this simple for MSSQL.

    0 讨论(0)
  • 2020-11-30 18:17

    I've done this off and on for years -- managing (or trying to manage) schema versions. The best approaches depend on the tools you have. If you can get the Quest Software tool "Schema Manager" you'll be in good shape. Oracle has its own, inferior tool that is also called "Schema Manager" (confusing much?) that I don't recommend.

    Without an automated tool (see other comments here about Data Dude) then you'll be using scripts and DDL files directly. Pick an approach, document it, and follow it rigorously. I like having the ability to re-create the database at any given moment, so I prefer to have a full DDL export of the entire database (if I'm the DBA), or of the developer schema (if I'm in product-development mode).

    0 讨论(0)
  • 2020-11-30 18:18

    I highly recommend SQL delta. I just use it to generate the diff scripts when i'm done coding my feature and check those scripts into my source control tool (Mercurial :))

    They have both an SQL server & Oracle version.

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