I am responsible for the database. It has about 126 sprocs, about 20 views, some UDF. There are several tables that store fixed configuration data for our various applications.
I am using a text file with one large text containing IF EXIST ... DELETE GO CREATE PROCEDURE ... for all sprocs, udfs, views and all attachments / updates for configuration scripts.
Over time, new sprocs have been added or existing sprocs have been modified.
The biggest mistake (as far as I know) that I created when creating this BIG text file was to use the code for the new / changed sprocs at the beginning of the text file. However, I forgot to exclude the previous code for new / changed sprocs. Let's illustrate this:
Say my BIG script (version 1) contains a script to create sprocs
sp 1 sp 2 sp 3 view 1 view 2
The database version table is updated with version 1.
Now there are a few changes in sp 2. So, now version 2 of the BIG script:
sp2 --> (newly added) sp1 sp2 sp3 view 1 view 2
So, obviously, running a BIG script version 2 will not update my sp 2.
I have long understood this with a 100+ number of sprocs.
Corrective Action:
I created a folder structure. One subfolder for each sproc / view.
I went through the latest BIG script from bgeinning and put the code for all the scripts in the appropriate folders. Some scripts are repeated several times in a BIG script. If there is more to create a specific sproc than on a block of code, I put the earlier version in another subfolder called "old" in the folder for that sproc. Fortunately, I always documented all the changes I made to all sprocs / view, etc. - I write down the date, version number and description of the changes made as a comment in the sproc code. This helped me figure out the latest version of code for sprocs when there are more than one block of code for sproc.
I created a DOS batch process to combine all the individual scripts to create my BIG script. I tried using .net streamreader / writer, which messed up the encoding and the "Β£" sign. Thus, I stick to the DOS batch for a while.
Is there a way to improve the whole process? Right now, I am somehow documenting a version of a BIG script along with its individual versions of sproc. For example, I like to have a way to document
Big Script (version 1) contains sp 1 version 1 sp 2 version 1 sp 3 version 3 view 1 version 1 view version 1 Big script (version 2) has sp 1 version 1 sp 2 version 2 sp 3 version 3 view 1 version 1 view 2 version 1
Any feedback is appreciated.