سؤال

We are currently reviewing the Source Control product as part of an automated developer deployment center.

We would like to be able to programmatically link a DB to source control, rather than relying on the developer doing this. Is this possible with RedGate SVN? If so, how?

Thanks David

هل كانت مفيدة؟

المحلول

You should be able to do what you are looking for with the command line of Red-Gate's SQL Compare Pro. It can script out the database and change only the files that are associated with changed objects in the database.

However, the process you are thinking of seems to be not beneficial. If you automatically check in a change from the database, you might catch something in the middle of a change leaving your source-code repository worthless. Instead you should have the developers check code in when they are done with the change.

If you are worried about them forgetting to check in, setup a continuous integration environment, that rebuilds the database from the repository and runs the tests against it. That will make sure that all objects are in source control.

If you do not have automated tests for you database code yet, take a look at tSQLt. It is a testing framework for SQL Server that makes writing tests simple. It is open source and you can get it here: tSQLt – The Database Unit Testing Framework for SQL Server. There is also a lot of information about how to write tests and how to set-up continuous integration with tSQLt on that site.

نصائح أخرى

You can use a product like OffScale DataGrove which will take complete snapshots of your entire database (data & schema) and is very easy to integrate with exiting source control.

Just make a hook to tag the database when you commit, by calling the following command:

datagrove tag -n=<svn-tag-id>

And if you want to automatically get the database that matched the commit when you check out, use an SVN hook to issue the following:

datagrove unload
datagrove load -n=<svn-tag-id>

DataGrove is simple to use and takes care of managing the database, so you don't have to. The version available now is free to download and use.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top