Search code examples
sql-serversvnversion-controlredgate

RedGate Programmatically Link DB to SVN


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


Solution

  • 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.