The application - Do you make sure that the database structure is handled automatically via 3 buttons "Create", "Upgrade" and "Reconcile"?
20/10/2010 7:57 PM by
You get an error message reported from a user like:
When I click the Save button on the product form it gives an error message about a missing field.
- Figure: The developer thinks "what could be wrong"
- Figure: The developer tests then replies "Works on my machine"
You try and reproduce it on your version in the office and everything works perfectly.
You suspect that the customer probably has changed the schema. So you start drafting an email to the user like:
Mary, I need you to send me your database schema as it might be different from what it should be. Can you:
- Open up Enterprise Manager in you are on SQL 2000 (or open SQL Management Studio if you are on SQL 2005, 2008 or 2010)
- Open the first tree
- Open the second tree
- Select your server
- Open that tree
- Select Databases
- Open that tree
- Select the database called Northwind
- Right click it and choose All Tasks, then Generate SQL Script
- Then select the options
- Then when I get this I will compare and I will make a script file for you to run and fix the problem
STOP! STOP! STOP!
It would be much better to just say:
Mary, click the "Reconcile" button and it will tell us what is wrong
Bottom line is the customers' database schema should always be correct, should be managed automatically by the app and if it is not, it is their problem.
Therefore, you should deliver an application with the buttons "Create", Upgrade" and "Reconcile", accessible via "Tools - Options" and a "Database" tab. We do this by using SSW SQL Deploy and throwing on the inherited user-control from the SSW.SQLDeploy.Options project.
For more information see Best Tools for SQL Server
It looks like this
Figure: When weird errors are happening at a client, you need a "Reconcile" button in your application. This compares the current scripts, to the client's database and tells you if things are not right Figure: First time your client opens the application, they will need to Creating a database. It should be as easy as clicking "Create"
As a developer, I promise to do these 3 things:
- Save every SQL change I do as a script
- Make sure the application I develop, has 3 buttons, "Create", "Update" and "Reconcile"
- Never ask a client to run a script
- Figure: Adam makes all his new developers swear in and repeat this
Do you feel this rule needs an update?