Skip to content

Commit 5e7e4e7

Browse files
committed
Improve deploy process
The dacpac deployment would remove the extended property before the upgrade was complete - allowing the GUI to connect before the version is upgraded. The property is now part of the dacpac. IsDBUpgradeInProgress is initially set to 'Y' and updated to 'N' at the end of the post deployment script. The deploy process also sets it to 'Y' before starting the deploy.
1 parent 57e1a73 commit 5e7e4e7

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

DBADash/Upgrade/DBValidations.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ WHERE type NOT IN('S','IT','SQ')
7373
)
7474
AND DB_ID()>4
7575
BEGIN
76-
SELECT '0.0.0.0' AS Version,@DeployInProgress AS DeployInProgress
76+
SELECT '0.0.0.0' AS Version,1 AS DeployInProgress
7777
END
7878
ELSE
7979
BEGIN
@@ -92,8 +92,11 @@ AND DB_ID()>4
9292
version = (string)rdr["Version"];
9393
deployInProgress = (bool)rdr["DeployInProgress"];
9494
}
95-
version ??= "0.0.0.1";
96-
95+
else // First time deployment is likely in progress
96+
{
97+
deployInProgress = true;
98+
version = "0.0.0.1";
99+
}
97100
return (Version.Parse(version), deployInProgress);
98101
}
99102

DBADashDB/DBADashDB.sqlproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@
841841
<Build Include="dbo\Functions\DatabaseSettingsUnpivot_Get.sql" />
842842
<Build Include="dbo\Stored Procedures\DeletedDatabases_Get.sql" />
843843
<Build Include="dbo\Stored Procedures\NewDatabases_Get.sql" />
844+
<Build Include="Database.sql" />
844845
</ItemGroup>
845846
<ItemGroup>
846847
<PostDeploy Include="Script.PostDeployment1.sql" />

DBADashDB/Database.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
Extended property indicates that a DB deployment is in progress, causing the GUI to pause and wait for it's completion
3+
Set to 'N' in post deployment script.
4+
Also set in the app code when an upgrade is initiated.
5+
*/
6+
EXECUTE sp_addextendedproperty
7+
@name = N'IsDBUpgradeInProgress',
8+
@value = 'Y';

DBADashDB/Script.PostDeployment1.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,4 +2068,10 @@ BEGIN
20682068
AND LR.DatabaseID = T.DatabaseID
20692069
)
20702070
DROP TABLE dbo.LogRestoresTemp
2071-
END
2071+
END
2072+
/*
2073+
Update extended property to indicate that a DB deployment is no longer in progress, allowing the GUI to continue loading.
2074+
*/
2075+
EXECUTE sp_updateextendedproperty
2076+
@name = N'IsDBUpgradeInProgress',
2077+
@value = 'N';

0 commit comments

Comments
 (0)