It has been announced, that future versions of the module installer in DotNetNuke will introduce an additional option in the manifest (.dnn) file for compatibility requirements as minimum DotNetNuke version, required by the module. But this does not prevent new module versions be installed on any previously published version. This can be a major problem, if the module requires a new version, that is not compatible with other installed modules and the SQL script already altered the database to work with the current module version only. So the new module version will not work and, as there is no downgrade skript, a reinstalled previous version will neither run. Uninstall is teh module definition no option, as all stored records of the module will be deleted. As a result, there are three survivor rules before an upgrade:
- back up your database
- check, if the backup did run
- check the prerequisites of the module
As we feared, that there are few users reading instructions and backups are somewhat non-sportive, we tried to find a solution, how to at least prevent the database from being updated, so the previous version can easily be re-installed. Therefore we extended the update SQL script:
We first compared the DNN version stored in the database with our requirements (DNN 3.3.0/4.1.0):
DECLARE @dnnVer INT
SET @dnnver = (SELECT TOP 1 Major*10000+Minor*100+Build FROM {databaseOwner}[{objectQualifier}Version] ORDER BY Major DESC, Minor DESC, Build DESC)
IF @dnnver < 30300 OR ( @dnnver >= 40000 AND @dnnver <40100)
RAISERROR ('Incompatible DotNetNuke framework version installed. Please upgrade to V. 3.3 or V. 4.1 or re-install previous version of this module!', 16, 1)
Unfortunately the script is still executed after the raised error, so we have to repeat this check before every statement (and even a local variable gets deleted after each GO statement).
So we extended the script using a temporarily used table:
CREATE TABLE UDT_Install_Semaphore (value INT PRIMARY KEY)
GO
DECLARE @dnnVer INT
SET @dnnver = (SELECT TOP 1 Major*10000+Minor*100+Build FROM {databaseOwner}[{objectQualifier}Version] ORDER BY Major DESC, Minor DESC, Build DESC)
IF @dnnver < 30300 OR ( @dnnver >= 40000 AND @dnnver <40100)
BEGIN
INSERT INTO UDT_Install_Semaphore (value) VALUES (0)
RAISERROR ('Incompatible DotNetNuke framework version installed. Please upgrade to V. 3.3 or V. 4.1 or re-install previous version of this module!', 16, 1)
END
ELSE
INSERT INTO UDT_Install_Semaphore (value) VALUES (1)
GO
IF (SELECT value FROM UDT_Install_Semaphore) = 1
...
GO
IF (SELECT value FROM UDT_Install_Semaphore) = 1
...
GO
...
DROP TABLE UDT_Install_Semaphore
GO
This way, the user can safely re-install the previous version of the module. However he will need to re-run this script manually from host::sql menu, as the module version is updated regardless this error.