Question

Context

  • I have a DNN 7 module that uses multiple tables.

  • I have the CREATE TABLE statements in separate files for clarity and ease of use.

  • My module's .dnn file has multiple entries for each script under the components tag.

Problem

When I install the module, only that last install script is executed (in the case of the example "CreateProductWidths"), ignoring the others.

Question

How can I run multiple scripts in separate files during installation? I have a total of 15 tables in this module, so it would not be conducive to have all of their definitions in one script. If it's too hard, I may be doing it wrong and I'm open to advice. Thanks.

Example

<component type="Script">
    <scripts>
        <basePath>DesktopModules\ProductManager</basePath>
        <script type="Install">
          <path>Providers\DataProviders\SqlDataProvider</path>
          <name>CreateProductCategories.SqlDataProvider</name>
          <version>00.00.01</version>
        </script>
        <script type="Install">
          <path>Providers\DataProviders\SqlDataProvider</path>
          <name>CreateProductFamilies.SqlDataProvider</name>
          <version>00.00.01</version>
        </script>
        <script type="Install">
          <path>Providers\DataProviders\SqlDataProvider</path>
          <name>CreateProductWidths.SqlDataProvider</name>
          <version>00.00.01</version>
        </script>
        <script type="UnInstall">
          <path>Providers\DataProviders\SqlDataProvider</path>
          <name>Uninstall.SqlDataProvider</name>
          <version>00.00.01</version>
        </script>
    </scripts>
</component>
Was it helpful?

Solution

Dilon,

I believe the DNN installation only supports one script file per version. Most of the time a modules CREATE TABLE/SPROC/VIEW script is in its first version, ie: 01.00.00. Then subsequent scripts will have alter table scripts or whatever is needed to change for that version. This is good practice because it allows you to manage your versioning. Also your scripts should be re-runnable in case the installation is repaired. Therefore your CREATE statements should be prefaced with IF EXISTS statements.

That being said, if you want to break out your scripts, you can set the package version to 01.00.00.

IE:

<package name="Module.Name" type="Module" version="00.01.00">

Then version your scripts differently, ie: "00.00.01", "00.00.02", "00.00.03", etc. DNN will run all scripts whose version is less than or equal to the package version number. It will also run them in version number order.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top