Archive
Monthly
Go
|
|
DNN Blog
Jan
10
Posted by:
Vicenç Masanas
1/10/2007 12:28 AM
There's some misunderstanding on how DotNetNuke Modules are installed and which steps are executed during a module installation or upgrade.
I'll try to cover both scenarios on this post and I hope this helps to get a clearer idea of how this works.
Let's first take a look at what happens when a module is installed:
As you may know all the internal versioning of modules (and even the core itself) is built around the <version> node on the .dnn installer manifest and the sql scripts that are included in the installation zip.
When the module is installed DNN will run all sql scripts with a number lower or equal than the one specified in the <version> node. Finally the version in that node will be saved on the DesktopModules table. This will help the core on future upgrades so it can know what version is currently installed.
First thing to note here: A given xx.xx.xx.SqlDataProvider script will only be run once. So no matter how many times you reinstall the same module, each sql script will only run once. This is great because otherwise you will see lots of errors when (for example) trying to create a table that already exists.
This gives to another point: if you had some trouble with a module (for example you removed a stored procedure accidentally during development), repeating the same process again (without first deinstalling the module) will not produce the same result.
So don't expect that reinstalling the same version that's currently installed will solve that problem. Can solve others, but not problems with the database.
Another thing that happens when you install a module is that it fires the "UpgradeModule" method if the module implements the IUpgradeable interface.
Public Interface IUpgradeable Function UpgradeModule(ByVal Version As String) As String End Interface
In fact this method will be called once after any sql script has been executed and it will be passed the version number of the current script. So you have to code your upgrade logic knowing that this method can be called multiple times. This is usually done testing for the Version parameter on a "select case" statement.
The method call will be routed through the EventQueue system after the web application is restarted. A minor difference with regards to how the sql scripts are executed exists though: even if there's no sql script on the module, this method will be called at least once. This is needed to be sure that at least the upgrade logic is executed, even if no sql script exists. So if you are installing a module whose final version will be 03.03.03, be sure that UpgradeModule will be called at least once with that version number.
Also notice that all UpgradeModule(..) calls will be made after all sql scripts have already run. This is true because they will be fired after the application is restarted and the end of the module installation process.
So again, be sure not to do something "strange" on your upgrade logic, assuming that the database has a special structure. For example query a given stored proc, you know in version 01.01.01 existed, because the code will be executed when all scripts for version 03.03.03 are already installed and maybe that stored proc. doesn't exist anymore.
On first time installations this is more or less all that's involved. Upgrading a module has a couple of differences worth noting.
What happens when a module is upgraded:
Execution of sql scripts is more or less the same: each file with a version number greater than the current version number stored on the DesktopModules table, and less or equal than the number included in the <version> node of the .dnn installer manifest will be run in order.
After each xx.xx.xx.SqlDataProvider script is run, the core will search for a corresponding "xx.xx.xx.txt" file on the upgrade package. This file can contain a list of files you want to remove from older versions of your module. You have to specify a file on any line using the relative path from the root of the DNN installation. For example:
bin\DotNetNuke.Modules.Survey.dll
bin\DotNetNuke.Modules.Survey.SqlDataProvider.dll
DesktopModules\Survey\c.gif
So if this file is 03.03.03.txt, and there's a 03.03.03.SqlDataProvider file, it will be "executed" just after the sqlscript and before the UpgradeModule for this version.
This is also another point where you have to make attention: the delete file will only be processed if there's a related sql script.
Afterwards the application is restarted all the UpgradeModule(...) will be called for each sql script that has been run before. Again, UpgradeModule will be called at least once for the final version (the one in the <version> node) , even if no sql script exists.
I hope this brief explanation helps to understand how DNN processes modules during installation and successive upgrades.
17 comment(s) so far...
Re: Installing and upgrading modules in DNN, a developer's view
IMHO it would be an advantage if the installer DID run the SqlDataProvider script that has the same version number as the current module version recorded in the DesktopModules table. In other words, a "reinstall" of a particular version could be attempted. I understand the concern that if the same SQL script is run twice the creation of new tables, data, procedures etc would fail (because they already exist). However, it is very easy to write the script to detect if the object already exists and only create it if it does not exist (for tables) or to delete and recreate it (for data and procedures).
For example:
-- Create table if not exists (select name from sysobjects where name = 'NAMEOFTABLE' and xtype = 'U') begin create table NAMEOFTABLE( COLUMN varchar(10) not null, etc ) end go
-- Create data delete NAMEOFTABLE where KEYFIELD = 'KEYVALUE'
insert NAMEOFTABLE ( KEYFIELD, OTHERFIELD ) VALUES ( 'KEYVALUE', 'OTHERVALUE' )
Is there another reason why this is not allowed?
By lneville on
2/8/2007 10:56 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
hi,
I was trying to follow your previous post on developing custom permissions and ran into a few problems, I'd appreciate it you could help.
DNN Version: 4.4.0 Steps: 1. In VS 2005, add a new item to the solution and select the custom module template in C# 2. Rename the default module name to the proper name 3. Added the UpgradeModule code and more from your previous post to the controller class 4. Set a break point on the 1st line of UpgradeModule 5. Start the project and log in as host 6. Go into Module Definitions 7. Click on the Create New Module link 8. Select myModule.dnn from the dropdown and click on the Install link
At this point, I expected the code should stop at the breakpoint I set but it never happened. Also, the SQL script never seemed to get executed, either. Am I missing something?
Thank you.
By linush on
2/8/2007 10:52 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
Also, is there a way to specify that my module is upgradable in the .dnn file? Why are those 3 checkboxes (Portable, Searchable, Upgradable) in the Edit Module Definitions page always disabled?
By linush on
2/8/2007 10:31 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
linush, If a module supports IUpgradable the installer will detect it and set the flags accordingly. You cannot set these flags from the UI, but I think this is something that could be improved. Vicenç
By vmasanas on
2/8/2007 10:52 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
linush, Regarding your first comment, I don't this this will work if run from the UI. The create modul from a dnn file feature is just a convenience for you as a developer in order to test the module features, not the installation procedure. If you want to test that part, you'll have to create a package and install it using the usual approach. Vicenç
By vmasanas on
2/8/2007 10:55 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
lneville, I understand what you mean but I don't think this is a problem of not being able to check the situation in the sql script. As you said this is quite easy. But I see a big problem in changing this now since most developers are used to think this works this way, and this will be considered as a BIG breaking change in DNN operation. Maybe we could have considered this in the beginning but now it's not an option. Also have in mind that this feature uses the same approach as the Core upgrades, so another reason to not change this, and maintain the coherence in all upgrade sections. Vicenç
By vmasanas on
2/8/2007 11:01 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
hi, very useful tutorial! my pblm is, i've downloaded upgrade module for IFrame just now. the download includes .dd,.dnn,resourses(zip file), dataprovider etc. so what i want to do now, place those files under "DesktopModules\Modules\IFrame" ? is any step by step tutorial available?pls. give me a link if it is or any idea? thanks in advance.
By vijee on
4/27/2007 10:37 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
vijee, what you should do is install the module as usual. The installer will place all the files in the right place for you. No need to do it manually. Vicenç
By vmasanas on
4/27/2007 10:38 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
Vicenç, thank you very much for ur reply. it works now.
By vijee on
5/4/2007 5:21 PM
|
Re: Installing and upgrading modules in DNN, a developer's view
Something to add to this great post: If you include a Install.SqlDataProvider in your zip, it will get run in case of a new installation instead of all the other scripts in order. Peter
By donker on
7/14/2007 6:58 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
Intalled the html text module upgrade, now getting this...what did I do wrong? How can I fix it? --- Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30560: 'DataProvider' is ambiguous in the namespace 'DotNetNuke.Modules.HTML'.
Source Error:
Line 40: Line 41: ' singleton reference to the instantiated object Line 42: Private Shared objProvider As DataProvider = Nothing Line 43: Line 44: ' constructor
Source File: D:\virtualhosts\johnsonfamilyhistory.org\wwwroot\App_Code\HTML\DataProvider.vb Line: 42
By justdavid on
8/13/2007 7:33 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
david: look on the \bin folder for dlls with the name DotNetNuke.Modules.HTML.dll and DotNetNuke.Modules.HTML.SqlDataProvider.dll. If any of these are present remove them.
By vmasanas on
8/13/2007 7:35 AM
|
Re: Installing and upgrading modules in DNN, a developer's view
Hello everybody.
I'm new in DNN.
I'm trying to find the way to install the source code of a module so I can customize it.
In particular I want to modify the Forum module (which is already installed). But in the installation that I have, I can't find the classes (only the ascx).
I have been googling all day and I didn't find any good article.
Can anybody help me??
Thaks!
By gsuarezt@hotmail.com on
5/20/2008 3:00 PM
|
Re: Installing and upgrading modules in DNN, a developer's view
Did you download the install package or the source package?
By zhlavinka on
6/25/2008 10:01 PM
|
Re: Installing and upgrading modules in DNN, a developer's view
hi,
I have installed DotNetNuke_04.08.04_StarterKit.vsi. Why I cant see all the modules like image module, IFrame module. Can anybody hepl me please?
By mshajamal on
9/8/2008 8:58 PM
|
Re: Installing and upgrading modules in DNN, a developer's view
hi,
I have installed DotNetNuke_04.08.04_StarterKit.vsi. Why I cant see all the modules like image module, IFrame module. Can anybody hepl me please?
By shajamal on
9/8/2008 11:18 PM
|
Re: Installing and upgrading modules in DNN, a developer's view
Can anyone proivde me proper steps to upgrade dnn modules in dnn applicaiton/website?
By Vyom Dixit on
2/19/2009 2:12 PM
|
|