mardi 10 juillet 2018

SQL Server - best way to validate sql schema and seed data

I am working on a web based app with a SQL server backend. This is a somewhat legacy app that I've just begun working on a few months ago and the database versioning situation is a bit of a mess. There is one set of scripts for a new install and another set for upgrading from version to version. Some of the scripts update the schema, others insert seed data. Other people, not developers, do the deployment and running of these scripts. Because of the versioning situation, there are sometimes issues with the scripts.

I'm revising the scripts to be more hardy, less likely to fail, and to have better logging when they do.

Meanwhile I want to do is create a validation script that we can run after a deployment. The script would runs and checks if all the necessary tables are there with the expected schema, and that the seed data scripts ran, everything is how it should be. Other than writing a ton of 'if not exists' (write to log) type statements, is there a better way to do this?

I can sometimes use Visual Studio schema compare to compare the newly updated db to an existing one, but data compare is not feasible in our environment.

Aucun commentaire:

Enregistrer un commentaire