Let's say we need all our application data (tables, storeds, ...) to be stored on a different database than the base DNN Sqlserver database. Will the module install feature provide any means for running the sql files on a different database?
The basic goal here would be to keep all DNN stuff in the DNN database and all application stuff in a separate database. But I don't want to loose the option of being able to install a new version of the module that will execute some SQL to update tables, sps, ...
Is that possible?
Thanks for the very helpful answer. It would be nice to see some code examples, particularly running SQL scripts on the external database during install or uninstall. It would be even nicer to see something that could be added to the dnndocs website!
Hans, thanks for the reply, but that's what not I was asking actually. I know we can do this and we already do this.
My question again is: when we install/update the module, is there a way to make the installer RUN the sql scripts against the different database or it always goes on the DNN database?
Would that be an interesting feature to add, or it's just me that finds this interesting?
I believe that in the script all you would need to add is a USE Database directive referening the name of your database name maintained in the web.config file.
Posted By Brian Dukes on 09 Aug 2019 11:58 AM It always runs against the DNN database. You could use IUpgradeable to run other scripts, or use linked databases to run scripts on the other database from the DNN database.
Yep... What he said ^^^
Whenever we need data to live in another data source, we use DNN's built-in functionality to install normally, then have a process migrate it after. For example, we do this a lot with custom modules that have PII.
Posted By HansZ on 09 Aug 2019 01:03 PM I believe that in the script all you would need to add is a USE Database directive referening the name of your database name maintained in the web.config file.
I haven't tried that specifically recently, but in my case, we're often using a different data source altogether (e.g., other server, other DB server, etc.) and it requires an additional data connection string instead of USE.
Oh, and to address an earlier comment... I wouldn't ever suggest putting any connection string details in the AppSettings. You should use the connectionStrings section in the web.config instead. :)
These Forums are dedicated to the discussion of DNN Platform.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.