Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Avoiding database bloatAvoiding database bloat
Previous
 
Next
New Post
7/19/2008 12:55 PM
 

I'm trying to find out how to make modules clean up after themselves when they're deleted, to avoid database bloat. So, when an editor deletes a module from a page, I want the module to remove all entries pertaining to itself from the relevant database tables.

Odd thing is, I haven't found any examples for this kind of thing anywhere. Am I not looking hard enough, or is there a reason why data from deleted modules needs to be kept? Can anybody point me in the right direction?

 
New Post
7/19/2008 2:45 PM
 

It's pretty easy actually and all the core modules implement it so you can check them out for examples - to ensure data is deleted add a foreign key relationship between the modules table and the moduleID field in your main table and set the relationship to cascade deletes. I'd also advise you to follow a similar pattern from your main database table to any dependant objects.

BTW I'd recommend that you download and read the module developers guide @ http://www.dotnetnuke.com/Resources/Documentation/DownloadableFiles/tabid/478/Default.aspx

Finally, to ensure that the objects are cleaned up when the module itself if uninstalled create a Uninstall.SqlDataProvider with statements to DROP the objects.

Cathal


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
7/20/2008 7:16 AM
 

Ok, that's what I originally thought (I'm not an SQL expert). As per your suggestion, I've had a look at the core modules to see if the syntax created by the module framework builder was screwy. However, during testing I noticed that the core modules seem to have exactly the same problem. As far as I can see, all core modules have a variation of the following in their SqlDataProvider file:

ALTER TABLE {databaseOwner}[{objectQualifier}HtmlText] WITH NOCHECK ADD CONSTRAINT [FK_{objectQualifier}HtmlText_{objectQualifier}Modules] FOREIGN KEY ([ModuleID]) REFERENCES {databaseOwner}[{objectQualifier}Modules] ([ModuleID]) ON DELETE CASCADE NOT FOR REPLICATION

This looks like what you're suggesting, but if I look at the table data for HtmlText, the content of each HTML module is added, but when I delete the module, the relevant entry stays in the table. Cross-checking the 'Modules' table, I can see that the row for the deleted module has its 'IsDeleted' property changed to 'true', but nonetheless the row is still there.

I'm using Visual Studio Express 2008 for development, so I tried running the following SQL query by hand on the 'Modules' table:

DELETE from Modules WHERE ModuleID=383

This deletes the module and cascades the delete correctly through to the HTML Text table.

While I find it reassuring that my modules do not behave differently from the core ones, I'm still stuck with the same problem: modules do not seem to clean up after themselves. Or is that just because of my development environment (VSE & SQL Express 2008)?

Thanks in advance for any help you can give me on this... :)

 
New Post
7/20/2008 11:37 AM
 

Frauke - the isDeleted flag and the delete functionality is working as expected. Try deleting another entry from the Text/HTML table and then go to your recycle bin (from under the Admin menu) and delete it permanently. It should now go away from the Text/HTML table.

The purpose of the IsDeleted flag is so that a user can undo a deletion if he/she did it by mistake...

Sanjay

 


AcuitiDP - Oracle Data Provider for DotNetNuke
 
New Post
7/21/2008 9:09 AM
 

Ah, yes, that's solved the mystery!

Thanks a million to both of you!

Frauke

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Avoiding database bloatAvoiding database bloat


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out