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