Is there a version control system for database structure changes?

后端 未结 22 1173
梦毁少年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:27

    You can use Microsoft SQL Server Data Tools in visual studio to generate scripts for database objects as part of a SQL Server Project. You can then add the scripts to source control using the source control integration that is built into visual studio. Also, SQL Server Projects allow you verify the database objects using a compiler and generate deployment scripts to update an existing database or create a new one.

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

    I wonder that no one mentioned the open source tool liquibase which is Java based and should work for nearly every database which supports jdbc. Compared to rails it uses xml instead ruby to perform the schema changes. Although I dislike xml for domain specific languages the very cool advantage of xml is that liquibase knows how to roll back certain operations like

    <createTable tableName="USER"> 
       <column name="firstname" type="varchar(255)"/>
    </createTable>
    

    So you don't need to handle this of your own

    Pure sql statements or data imports are also supported.

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

    For Oracle, I use Toad, which can dump a schema to a number of discrete files (e.g., one file per table). I have some scripts that manage this collection in Perforce, but I think it should be easily doable in just about any revision control system.

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

    I write my db release scripts in parallel with coding, and keep the release scripts in a project specific section in SS. If I make a change to the code that requires a db change, then I update the release script at the same time. Prior to release, I run the release script on a clean dev db (copied structure wise from production) and do my final testing on it.

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