I want to write a SQL migration tool. This tool must:<ul><li>merge new scripts in a folder,</li> <li>validate the merging of those scripts, </li> <li>run those scripts against a database. </li> <li>if a validation error occurred, then highlight the invalid rows.</li> <li>if the script was successful deployed, I want to save this information in a database with the version and other related information. </li> </ul>
Can I do this with some validation framework, or maybe can I use nHibernate?Answer1:
Not exactly what your asking for but I think I know what your trying to achieve.
<a href="http://code.google.com/p/migratordotnet/" rel="nofollow">http://code.google.com/p/migratordotnet/</a>
<a href="http://ayende.com/Blog/archive/2009/05/01/nhibernate-validator.aspx" rel="nofollow">http://ayende.com/Blog/archive/2009/05/01/nhibernate-validator.aspx</a>
And also Schema Updater (part of NHibernate)
This blog has a code sample. <a href="http://morten.lyhr.dk/2008/03/nhibernates-schemaupdate-feature.html" rel="nofollow">http://morten.lyhr.dk/2008/03/nhibernates-schemaupdate-feature.html</a>Answer2:
A little bit late to the party here, but this is a good addition to the list:-
<strong><a href="https://github.com/schambers/fluentmigrator" rel="nofollow">FluentMigrator</a></strong>
FluentMigrator is a database migration framework for .NET written in C#. The basic idea is that you can create migrations which are simply classes that derive from the Migration base class and have a Migration attribute with a unique version number attached to them. Upon executing FluentMigrator, you tell it which version to migrate to and it will run all necessary migrations in order to bring your database up to that version.
In addition to forward migration support, FluentMigrator also supports different ways to execute the migrations along with selective migrations called profiles and executing arbitrary SQL.Answer3:
Try DBSourceTools. <a href="http://dbsourcetools.codeplex.com" rel="nofollow noreferrer">http://dbsourcetools.codeplex.com</a> <br /> By using the patching engine, it will allow you to reliably test patch scripts against a database at a known state.<br /> It is an open source tool that combines features of Visual Studio Database Edition and MSSQL Management Studio.<br /> Ideally, you would want to test all scripts that you are running in any sort of migration.<br /> Why would you need to store whether a validation error occurred in a script ?<br /> Surely this means that the script was not tested correctly ?<br /> Have fun.