The script component is used execute SQL scripts on the database. It is usually used by modules to install and/or upgrade the tables and stored procedures required for their data storage needs.
The Script Component inherits from the File Component
and uses a similar sintax.
All SQL scripts must be named by using a format like "version
- version is the sequential version number of the script (this will be used to execute the scripts in the correct order), for example "00.00.01"
- dataprovidertype identifies the dataprovider being used. By default DNN uses the SQL Server DataProvider identified by "SqlDataProvider" (for example: "00.00.01.SqlDataProvicer"). Other data providers might use other prefixes. The data provider definition can be found on the web.config file on the "data" section group.
When upgrading a package only scripts with a version greater than the currently installed version will be executed.
Elements and attributes
<scripts> <basePath /> <script [type="Install | UnInstall"] > <path/> <name/> <version/> </script>
- type: identifies if the script will be used when installing or uninstalling the package. An uninstall script must be named explicitely "uninstall.*" otherwise will not be executed when uninstalling the package.
- basePath: where the scripts will be saved after installation
- path: the folder where the script will be copied (relative to basePath)
- name: the name of the script file
- version: sequential version of the script file, used to correctly execute the scripts in the right order
The Script component supports two special names for scripts that will be considered in a different way than usual scripts:
- install.SqlDataProvider: if the package is being installed for the first time, this script will be executed before all other scripts
- upgrade.SqlDataProvider: after all regular scripts have been executed, DNN will process this script if present. If there is an "upgrade" script on the package it will be executed ALWAYS as the final script
<scripts> <basePath>DesktopModules\MyModule</basePath> <script type="Install"> <path>providers\dataproviders\sqldataprovider</path> <name>03.01.00.sqldataprovider</name> <version>03.01.00</version> </script>
<script type="UnInstall"> <path>providers\dataproviders\sqldataprovider</path> <name>uninstall.sqldataprovider</name> <version>05.01.01</version> </script>