Script Component

Return to previous page

  • 4/7/2015
  • 2782 Views

Comments

2782 Views

Script Component

Last updated 6 years ago

Comments

Common

(Enter the content of this article below)

Advanced

 
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.dataprovidertype", where:
  • 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


<component type="Script">

<scripts> <basePath /> <script [type="Install | UnInstall"] > <path/> <name/> <version/> </script>
</scripts>
</component>

  • 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


Sample

<component type="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>
</scripts>
</component>


References

Contents
No sections defined
Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out