DotNetNuke (DNN) is very good CMS. It allows easy and fast build new modules without any problems. Furthermore it allows to do an upgrade of old modules with beautiful and perfect process. For example, we have Module with version 01.00.00. During installation all SQL scripts locate in the 01.00.00.SqlDataProvider. This file contains all required SQL for correct Module functionality.
In case you need to upgrade your module, then all what you do is add to your module new file, like 01.00.01.SqlDataProvider. During installation DNN framework checks current version and runs all scripts above current version. It allows to do cumulative upgrade without any problems.
But some clients do an upgrade manually and it can be a lot of headache. So here is a way how to protect your SQL script:
IF(
NOT EXISTS(
SELECT sc.name
FROM syscolumns sc
WHERE (sc.id IN
(SELECT so.id
FROM sysobjects so
WHERE so.name='{objectQualifier}Survey'))
AND
(sc.name='CategoryID')
)
)
BEGIN
ALTER TABLE {databaseOwner}{objectQualifier}Survey ADD CategoryID int NOT NULL DEFAULT(0)
END
As you see, this script checks for field before creation. So, do not need to worry customer runs it twice or more times.
PS: My old teacher said: Good code allows to remove half of lines and continues to work :)
This comment has been removed by a blog administrator.
ReplyDelete