I don't think I'm seeing this. Here's our pre-deploy script:
IF exists(SELECT 1 FROM sys.databases WHERE name = N'BACKUPDB') and exists(SELECT 1 FROM sys.databases WHERE name = N'NEWDB')
BEGIN
EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'NEWDB'
DROP DATABASE [NEWDB]
End
When I change the Database Name on Server field in the last screen of the DDT Wizard from "NEWDB" to "NEWDB123", I get a really long delay (maybe a minute?) at:
Ensuring Tables exist on database 'NEWDB123'
Although no errors show up. However, I get a ton of errors when running the Post-Deployment Scripts related to a primary key constraint error trying to insert duplicate keys into the tables. It doesn't seem like "NEWDB123" is being deleted. If I run the DDT again and change the Database Name on Server field back to the original "NEWDB" and run it. I get no delay at the beginning and all scripts run with no errors.
What am I missing here?!