开发者

Create "Update Scripts" for a database project?

开发者 https://www.devze.com 2023-02-06 05:18 出处:网络
As I release versions of software and branch versions for each release, how can I easily generate update/patch scripts for the versions? I can\'t open the database projects and compare them because th

As I release versions of software and branch versions for each release, how can I easily generate update/patch scripts for the versions? I can't open the database projects and compare them because they are named the same and visual studio doesn't like that.

The next idea I had was deploying lower version to a database and then generating a change script by opening up the next version of the software. This seems like it would be a bit tedious.

Also, how would one go about integrating this into a setup project instead o开发者_如何学JAVAf a manual process?


Even if you were using the new Entity Framework you still can't get Visual Studio etc to track changes in a database schema automatically for you, you'd have to track the changes between versions manually and apply them (usually when the upgraded app runs for the first time).

I would suggest...

  1. Adding a version identifier to your database schema in some table.
  2. Tracking all database schema changes between versions, if you use MySQL for example, then Toad will make a repository (SVN for example) commit every time you make a schema change, which makes logging changes easier.
  3. When you deploy a new version, tally up all your schema changes and mark them as the change set from version Y to version Z.
  4. When your app runs for first time (so not with the setup program but with the app itself), lookup the version in the schema, and apply each update script until you reach the version of the app. So if the app runs and discovers schema X, it'll run script Y and then script Z.

This is how most apps run, wordpress, blogengine.net for example; all run in this mannor, when releasing they provide one script to create the schema from scratch, and another to update it from the last released version.

0

精彩评论

暂无评论...
验证码 换一张
取 消