When I started with Thinkwise a few years ago our team was not completely using the Creation steps the way I was taught during the training.
For completeness: we usually add a column, table or domain to TW and manually add it to the db using SSMS. The problem is that it is easy to forget to add the correct constraints etc… So periodically I would delete my DEV version and rebuild the db from scratch and then compare (using Redgate SQL compare) DEV to TEST, ACC and PROD.
I'm trying to correct that but I keep running into situations that I need to manually alter the existing db.
I've started out with a newly generated db for branche A and did some development work on this branch
In branch B I've added a new column to a table and did some development that uses that column
Now I’ve merged A and B to MAIN and made a new branch from MAIN which I'll call branch C
When I load the new combined branch C I can see that the new column from branch B is existing.
But when I run Creation > Generate definition > Validate definition > Generate source code > Execute source code the new column is not being added resulting in an error when it tries to create/alter the stored procedure that uses this particular column.
I expected TW to know that the most recent build/deployed db was branch A and the current branch is a combination of A and B so it needs to alter that table and add the column.
But apparently there is something wrong in how I expected it to work :)
Obviously I can fix this because on DEV I can delete the entire db and force a complete rebuild (and manually sync the master data from PROD back into the db) or manually do the ALTER TABLE ADD COLUMN query but this isn't the correct way I suspect :p
Next would be deploying to PROD and obviously it's not an option to drop the entire db there…
For now I was planning on only deploying to DEV and use RedGate SQL Compare to deploy differences in the data model manually to the rest of the OTAP/DTAP street.
Solved
Creation doesn't add newly added column
Best answer by Anne Buit
The best way to go about the database being out of sync with the model on datatypes is to change the datatype twice, subsequently.
For example, the domain last_name in the model is nvarchar(100)
but on the database is is actually nvarchar(50)
.
Change the datatype from the incorrect domain from nvarchar(100)
to nvarchar(50)
, perform an upgrade (this will have no actual effect on the upgraded data and schema). Change the datatype back to nvarchar(100)
and upgrade again.
The model and database are now once again in sync.
The same can be done for a missing column.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.