Delete / CleanUp a module created by Module Builder
How can I in my development environment delete a either failed module or a module just used for testing from the config & database?
This is just used in the development of a new site.
I've tried to manually go inte the database and delete created tables and content in some tables but I'm having problems manually delete a failed module, I probably don't know all the places a module get's created in.
/Keivan
Hi Keivan,
I highly recommend you, not to try to delete randomly from the database. The explanation for not being able to delete a module, once you have created it, is given in the link i am sending you.
Is it possible to delete module
If you have further questions about the module builder, feel free to ask me.
Happy Holidays,
Dimitar Dimitrov
Sitefinity team
Hi
I've already read this, the problem is that the only option I'm left with is to start from scratch which I've done to many times before during development, so I would just like to know how to manually delete any leftovers during development.
I hade one problem with a module not been created correctly, and to continue development I hade to start from a empty database and that wasn't really what I wanted to spend my time on doing. It's very difficult to get everyting right at the first atempt especially when developing some custom controls in the module builder.
/Keivan
Hi Keivan,
I have managed to delete a module by cleaning the database, so here are the steps I have taken:
1. Start from the table: sf_meta_types -> find your module there, write down his ID, and delete the row.
2. Go to sf_meta_fields -> find all fields there, whose type_id is the one of your module and delete them.
3. Delete the tables, holding your items. If you have created a module with developer name: deleteMeModule
you can find the tables by that name.
4.Find the tables sf_mb_dynamic_module, sf_mb_dynamic_module_field, sf_mb_dynamic_module_type and delete from there your module, the corresponding type and all fields, whose parent type id is your module type. Also delete the sections for your type from sf_mb_fields_backend_section.
By this moment, should be removed from your Sitefinity Project, should not be visible in the Administration -> Module Builder.
Still the module appears under the Content menu item. Here is how I removed it from there:
1. Go to sf_page_data and find your module by the title_ and write down the content_id.
2. Go to sf_page_data_attributes and find the module either by the name or the content_id and delete it.
3. Go to sf_page_data_sf_language_data and find your module by the content_id and delete it.
4. Delete the module from sf_page_data
5. Next go to sf_page_node and find your module again and write down the id.
6. Go to sf_page_node_attributes and find your module by the id or by the name and delete all rows you find.
7. Go to sf_page_node_sf_permissions and delete the row with id of the module id in sf_page_node.
8. Go to sf_pg_nd_sf_prmssns_nhrtnc_map and delete the row with the module id.
9. Delete the module from sf_page_node
Doing this steps worked for me, but I cannot guarantee you, that there are no leftovers somewhere, but currently, you will not get any exception.
I think, we are going to implement the automatic delete for a module in the next release, but you can try this at the moment.
If you still have some problems, feel free to write me and I'll try to investigate too, what could be the problem.
All the best,
Hi,
Here is a short script to automate the deletion instruction written by Dimitar Dimitrov.
Ive used this script a few times to delete and clean the db from a dynamic module icreated by the module builder without exceptions and errors (just remember to restart the app).
DECLARE
@MetaId uniqueidentifier
DECLARE
@TypeId uniqueidentifier
DECLARE
@ParentTypeId uniqueidentifier
DECLARE
@ContentId uniqueidentifier
DECLARE
@PageNodeIds
TABLE
( id uniqueidentifier )
DECLARE
@ModuleNamespace nvarchar(255)
DECLARE
@ModuleClassName nvarchar(255)
DECLARE
@ModulePageTitle nvarchar(255)
DECLARE
@ModuleTableName nvarchar(255)
SET
@ModuleNamespace =
'Telerik.Sitefinity.DynamicTypes.Model.ModuleName'
SET
@ModuleClassName =
'ModuleName'
SET
@ModulePageTitle =
'ModuleTitle'
BEGIN
TRANSACTION
BEGIN
TRY
PRINT
'Start Removing Dynamic Module.'
PRINT
'Removing Meta Type.'
SET
@MetaId = (
SELECT
[id]
from
sf_meta_types
WHERE
[name_space]=@ModuleNamespace
AND
[class_name]=@ModuleClassName)
DELETE
FROM
sf_meta_fields
WHERE
[type_id]=@MetaId
DROP
TABLE
module_table
PRINT
'Removing Module Builder Meta Type.'
SET
@TypeId = (
SELECT
[id]
from
sf_mb_dynamic_module_type
WHERE
[type_namespace]=@ModuleNamespace
AND
[type_name]=@ModuleClassName)
SET
@ParentTypeId = (
SELECT
[parent_module_id]
from
sf_mb_dynamic_module_type
WHERE
[type_namespace]=@ModuleNamespace
AND
[type_name]=@ModuleClassName)
DELETE
FROM
sf_mb_dynamic_module_field
WHERE
[parent_type_id]=@TypeId
DELETE
FROM
sf_mb_fields_backend_section
WHERE
[parent_type_id]=@TypeId
DELETE
FROM
sf_mb_dynamic_module_type
WHERE
[id]=@TypeId
DELETE
FROM
sf_mb_dynamic_module
WHERE
[id]=@ParentTypeId
PRINT
'Removing Page Data.'
SET
@ContentId = (
SELECT
[content_id]
from
sf_page_data
WHERE
[title_]=@ModulePageTitle)
DELETE
FROM
sf_page_data_attrbutes
WHERE
[content_id]=@ContentId
DELETE
FROM
sf_page_data_sf_language_data
WHERE
[content_id]=@ContentId
DELETE
FROM
sf_page_data
WHERE
[content_id]=@ContentId
PRINT
'Removing All Page Nodes.'
INSERT
INTO
@PageNodeIds (id)
SELECT
[id]
from
sf_page_node
WHERE
[title_]=@ModulePageTitle
DELETE
FROM
sf_page_node_attrbutes
WHERE
[id]
in
(
SELECT
[id]
FROM
@PageNodeIds)
DELETE
FROM
sf_page_node_sf_permissions
WHERE
[id]
in
(
SELECT
[id]
FROM
@PageNodeIds)
DELETE
FROM
sf_pg_nd_sf_prmssns_nhrtnc_map
WHERE
[id]
in
(
SELECT
[id]
FROM
@PageNodeIds)
DELETE
FROM
sf_page_node
WHERE
[id]
in
(
SELECT
[id]
FROM
@PageNodeIds)
COMMIT
TRANSACTION
PRINT
'Dynamic Module Removed.'
END
TRY
BEGIN
CATCH
ROLLBACK
TRANSACTION
DECLARE
@Msg NVARCHAR(
MAX
)
SELECT
@Msg=ERROR_MESSAGE()
RAISERROR(
'Error Occured: %s'
, 20, 101,@msg)
WITH
LOG
END
CATCH
Hello guys,
The module deletion will be supported in the upcoming release, so you won't need to do anything like this.
Regards,
[deleted for your server problems...]
Hi Dimitar,
Which release will support it? We use version 4.4, not 5. And, waiting for some fixations in v4.x. Will you release as v4 with some fixations ?
Onur
Hello Onur,
Unfortunately there are no new fixes planned for Sitefinity 4.4. The previously described functionality is included in Sitefinity 5.0.
Kind regards,
Victor Velev
the Telerik team
@Crema
Just upgrade to 5...it's just a new major version in name only (really). It's not like a new codebase or anything like going from telligent 5-6 or sitefinity 3-4
The module builder enhancements in 5 (the import\export) are well worth it anyway.
Steve