dataplat / dbops

⚙ dbops - Powershell module that provides continuous database deployments on any scale
MIT License
157 stars 39 forks source link

Issue during install several scripts #165

Open erikpassadore opened 4 days ago

erikpassadore commented 4 days ago

Hi, I'm using this tool to automatically update the structure of my database during the deployment process. I have a folder with all scripts from version 000001.sql to version 000020.sql

Before creating of the last script (000020.sql) I didn't have any problems, but now the tool doesn't update the database. For example: I have to update a DB where scripts number 11,12,13 and 20 are missing. The result of the Install-DBOScript command is the following, but the database is not updated.

image

Do you have any idea what the problem might be?

nvarscar commented 3 days ago

Could you run this with a -Debug switch and see if there's extra output that could be useful? The only reason for this behaviour I can think of is that one of the scripts has a statement that changes the DB context (like USE in SQL Server); in such scenario the journal in the current database won't register your changes.

erikpassadore commented 3 days ago

I tried to run the command with the -Debug parameter and that is the result:

image

But, I found that the problem is related to the script 000011.sql because this script start a transaction, make some changes to the DB and (for unknow reason) the transaction still pending. Removing this transaction all scripts are executed fine. The quesiton is, why DBOPS return the "Upgrade successful" also if I have this issue?

Thank's a lot for your help.

nvarscar commented 2 days ago

The quick answer here is that the underlying framework (DbUp) is reporting the deployment as successful, but I guess what really happens is that once the connection is terminated, the transaction is rolled back. I'll have to play with it to see if it's even possible to detect, if that's the case.