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

HomeHomeGetting StartedGetting StartedInstalling DNN ...Installing DNN ...Manual Deletion of Bad Portal InstallationsManual Deletion of Bad Portal Installations
Previous
 
Next
New Post
3/16/2006 11:54 AM
 

A number of us have been having yet-to-be-resolved problems with getting errors when attempting to add new portals.  See: http://www.dotnetnuke.com/Community/ForumsDotNetNuke/tabid/795/forumid/107/threadid/22107/scope/posts/Default.aspx
http://www.dotnetnuke.com/Community/ForumsDotNetNuke/tabid/795/forumid/108/threadid/22704/scope/posts/Default.aspx
http://www.dotnetnuke.com/Community/ForumsDotNetNuke/tabid/795/forumid/108/threadid/19372/scope/posts/Default.aspx
http://www.dotnetnuke.com/Community/ForumsDotNetNuke/tabid/795/forumid/108/threadid/23099/scope/posts/Default.aspx

While I still can't get to the bottom of the problem, I know a side concern has been deleting these bad portals when the errors won't let us access the site settings page to do so.  I have yet to see a solid answer for this, so I went ahead and took a stab at writing a SQL Script to do it.  I am FAR from expert on these things, so it would be great if someone with more experience could take a look.  Are there any major gaps that I'm missing?

The Script:

--* SCRIPT FOR MANUAL DELETION OF PORTALS
--* Particularly designed for portals with errors in their installations that make
--* the standard DNN deletion method impossible.

--* Reference variable for script.

DECLARE @badportal int

Replace ### below with the portalID number of the portal to be deleted

SET @badportal = ###

--* Deleting portal-specific aspnet_ data

DELETE aspnet_applications
FROM aspnet_applications
LEFT OUTER JOIN aspnet_roles ON aspnet_Roles.ApplicationId = aspnet_Applications.ApplicationId
LEFT OUTER JOIN aspnet_usersinroles ON aspnet_usersinroles.roleid = aspnet_roles.roleid
WHERE aspnet_applications.applicationname = @badportal

--* Deleting portal roles

DELETE Roles
FROM Roles
LEFT OUTER JOIN UserRoles ON UserRoles.RoleID = Roles.RoleID
WHERE Roles.PortalID = @badportal


DELETE userportals
FROM userportals

--* The following code deletes all user data for users connected to the portal.
--* IMPORTANT: If the user you assigned as the admin during protal creation was
--* a prexisting user that you use with other portals, DELETE THE FOLLOWING LINES

LEFT OUTER JOIN users on users.userid = userportals.userid
LEFT OUTER JOIN aspnet_users on users.username = aspnet_users.username
LEFT OUTER JOIN aspnet_membership on aspnet_users.userid = aspnet_membership.userid
LEFT OUTER JOIN aspnet_profile on aspnet_profile.userid = aspnet_membership.userid

--* End optional delete

WHERE userportals.portalid = @badportal

--* Deleting Skins, Files, and Folders

DELETE Skins
FROM Skins
WHERE Skins.PortalID = @badportal

DELETE Files
FROM Files
WHERE Files.PortalID = @badportal

DELETE Folders
FROM Folders
LEFT OUTER JOIN FOlderPermission ON Folders.FolderID = FolderPermission.FolderID
WHERE Folders.PortalID = @badportal

--* Deleting Modules and associated data

DELETE Modules
FROM Modules
LEFT OUTER JOIN TabModules ON Modules.ModuleID = TabModules.ModuleID
LEFT OUTER JOIN ModulePermission ON Modules.ModuleID = ModulePermission.ModuleID
LEFT OUTER JOIN ModuleSettings ON Modules.ModuleID = ModuleSettings.ModuleID

--* You will need to add joins for any databases utilized in modules present in the portal
--* If you are unclear cross-reference the modules.moduledefID entries for you protal
--* with the ModuleDefinitons table.  Here are example joins for common module types

LEFT OUTER JOIN HtmlText ON HtmlText.ModuleID = Modules.ModuleID
LEFT OUTER JOIN UserDefinedFields ON UserDefinedFields.ModuleID = Modules.ModuleID

WHERE Modules.PortalID = @badportal

--* Deleting Tabs

DELETE Tabs
FROM Tabs
LEFT OUTER JOIN TabPermission ON Tabs.TabID = TabPermission.TabID
WHERE Tabs.PortalID = @badportal

--* Final Portal Deletion

DELETE Portals
FROM Portals
LEFT OUTER JOIN POrtalAlias ON Portals.PortalID = PortalAlias.PortalID
WHERE Portals.PortalID = @badportal

 
New Post
4/25/2006 9:45 AM
 

Hi

Did you get anywhere with this? please let us know.

Thanks

Alex

p.s.

Query to cross reference modules (find out what modules are installed in your portal, see statement posted above in original post:

SELECT DISTINCT  dnn_ModuleDefinitions.FriendlyName
FROM dnn_ModuleDefinitions INNER JOIN
dnn_Modules ON dnn_ModuleDefinitions.ModuleDefID = dnn_Modules.ModuleDefID
WHERE dnn_Modules.PortalID = @badportal
Order by dnn_ModuleDefinitions.FriendlyName



Alex Shirley


 
New Post
7/20/2006 6:54 PM
 

Well I tried it, all good except this part of the query does not work with DNN 4.0.3:

DELETE aspnet_applications
FROM aspnet_applications
LEFT OUTER JOIN aspnet_roles ON aspnet_Roles.ApplicationId = aspnet_Applications.ApplicationId
LEFT OUTER JOIN aspnet_usersinroles ON aspnet_usersinroles.roleid = aspnet_roles.roleid
WHERE aspnet_applications.applicationname = @badportal

I get:

Msg 547, Level 16, State 0, Line 15
The DELETE statement conflicted with the REFERENCE constraint

"FK__aspnet_Ro__Appli__0CDAE408". The conflict occurred in database "DNNDatabase", table

"dbo.aspnet_Roles", column 'ApplicationId'.
The statement has been terminated.

I'm trying to revise this part of the query but without much success. It's appears to be the relationship between aspnet_roles and aspnet_applications that is preventing things here.

Any ideas?


Cheers

Alex



Alex Shirley


 
New Post
7/20/2006 9:31 PM
 
I have a free module that deletes portals:
Portal Delete Module

It was developed and tested in 3.2.  It has a number of bells and whistles.  Source version also available.

Let me know if anyone has any problems with 4.x and I'll update it.

Wylie



Chris Wylie
Chief Executive Officer
www.AccordLMS.com
1775 W. State Street Suite 371, Boise ID 83702 USA
 
 
New Post
7/24/2006 9:08 PM
 

OK I think I have the right statement now to delete the AspNet data....
As below. Let me know if you see any issues.
Maybe somebody would like to combine the statements, add anything they see might be missing and post it here.
A clean DNN installation is a good installation .... er so my mother said.

Cheers

Alex

/** Remove AspNet Data **/

DECLARE @badportal nvarchar(256)

SET @badportal = '####'


/** Delete Profile **/
DELETE aspnet_Profile
FROM aspnet_Applications
INNER JOIN aspnet_Users ON aspnet_Applications.ApplicationId = aspnet_Users.ApplicationId
INNER JOIN aspnet_Profile ON aspnet_Users.UserId = aspnet_Profile.UserId
WHERE (aspnet_Applications.ApplicationName = @badportal)

/** Delete Membership **/
DELETE aspnet_Membership
FROM aspnet_Applications
INNER JOIN aspnet_Membership ON aspnet_Applications.ApplicationId = a
spnet_Membership.ApplicationId
WHERE (
aspnet_Applications.ApplicationName=@badportal)

/** Delete UsersInRoles **/
DELETE aspnet_UsersInRoles
FROM aspnet_Applications
INNER JOIN aspnet_Users ON aspnet_Applications.ApplicationId = aspnet_Users.ApplicationId
INNER JOIN aspnet_UsersInRoles ON aspnet_Users.UserId = aspnet_UsersInRoles.UserId
WHERE (
aspnet_Applications.ApplicationName=@badportal)

/** Delete Users **/
DELETE aspnet_Users
FROM aspnet_Applications
INNER JOIN aspnet_Users ON aspnet_Applications.ApplicationId = aspnet_Users.ApplicationId
WHERE (
aspnet_Applications.ApplicationName=@badportal)

/** Delete Roles **/
DELETE dbo.aspnet_Roles
FROM dbo.aspnet_Applications
INNER JOIN dbo.aspnet_Roles ON dbo.aspnet_Applications.ApplicationId =
dbo.aspnet_Roles.ApplicationId
WHERE (
dbo.aspnet_Applications.ApplicationName=@badportal)

/** Delete Applications **/
DELETE dbo.aspnet_Applications
WHERE (
ApplicationName=@badportal)

 



Alex Shirley


 
Previous
 
Next
HomeHomeGetting StartedGetting StartedInstalling DNN ...Installing DNN ...Manual Deletion of Bad Portal InstallationsManual Deletion of Bad Portal Installations


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