This project is read-only.
Current release works with SVN and SQL 2008 only!

Can work with SQL 2005, but you would need to change references for SMO, etc in the code. I originally wrote this against 2005, but now I use 2008 so I don't have a 2005 box to write against.

It is a little kludgey to get started but once you have this set up it works.

1) in SVN, create a repository
2) create a folder for each server under that repo
so for example you would have a svn repo

DatabaseSchemas
...MyDBServer

Now, create a folder somewhere on the computer you are going to run the app.

c:\DatabaseSchemas

and then check out each "server" folder, so in the above case i would checkout the "MyDBServer" folder under c:\DatabaseSchemas

now, the App.Config, pretty self explanitory, you set the path to the main folder, and the RunSteps (more on that in a bit).. if you have authentication for your Repo, set the boolean accordingly and set the user/pass, if you want to get emails if the app errors, you can set that up as well.

<add key="MainFolderPath" value="C:\DatabaseSchemas" />
<add key="RunStepsPath" value="C:\DatabaseSchemas\RunSteps.xml" />
<add key="SVNAuthentication" value="true" />
<add key="SVNUserName" value="dbschema" />
<add key="SVNPassword" value="pw" />
<add key="EmailOnError" value="true" />
<add key="EmailServer" value="" />
<add key="EmailFrom" value="" />
<add key="EmailTo" value="" />

RunSteps.xml tells the app what servers and databases to log, and what SQL Agent jobs to log from servers.

<?xml version="1.0" encoding="utf-8" ?>
<LogServers>
<LogJobs>
<server serverName="server1" />
<server serverName="server2" />
</LogJobs>

<LogObjects>
<server serverName="server1" databaseName="^(?!model$|master$|msdb$|tempdb$|ReportServer$|ReportServerTempDB$)" />
<server serverName="server2" databaseName="." /> <!-- a single period will always match, so this will sync ALL databases (including system dbs) -->
</LogObjects>
</LogServers>


Once you have that set up, you can schedule the app to run on an interval. I set mine to run every day. I use "Unfuddle" for SVN hosting and I can get commit alerts, so I can get alerts when my database schemas change. If you have a local repo, you would have to set up your own commit alerts.

You must have SVN cmd line on the machine that runs this app, or it won't work.

Also note, if something goes awry, the working copy may need a cleanup and manual commit OR revert. If you don't see commits coming through, try a SVN cleanup, revert, or commit manually. If all else fails, just delete and re-checkout the working copy and run the app again.

Last edited Apr 7, 2011 at 3:32 PM by tlaqua, version 7

Comments

No comments yet.