Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i remove module's data from Orchard database?

i have installed a module and after the migration and creating tables in Orchard.sdf i want to clear all tables and rollback all changes that the migration did.

I dropped the tables but i guess some metadata should be removed.

how we can clear a modules data completely? thanks.

like image 932
Ali Adlavaran Avatar asked Oct 24 '12 20:10

Ali Adlavaran


2 Answers

A complete uninstall involves deleting the database tables and rows that are associated with your module's name, the names of its features, and of its namespaces. Here is a process that worked for us.

1: Run orchard.exe > package uninstall Orchard.Module.MyModuleName

2: Then, open SQL Server Management Studio and drop the following database table(s) that are associated with your module.

MyModuleName_MyFeatureNameRecord

3: Do a wildcard search of the following table columns. Be sure to search for MyModuleName, MyNamespaceName, MyFeatureName, etc. You will eventually delete all these rows, but not yet.

SELECT *  FROM Orchard_Framework_ContentTypeRecord  WHERE Name LIKE '%%'
SELECT *  FROM Settings_ContentTypeDefinitionRecord  WHERE Name LIKE '%%'
SELECT *  FROM Settings_ContentPartDefinitionRecord  WHERE Name LIKE '%%'
SELECT *  FROM Settings_ShellFeatureRecord  WHERE Name LIKE '%%'
SELECT *  FROM Settings_ShellFeatureStateRecord  WHERE Name LIKE '%%'
SELECT *  FROM Orchard_Framework_DataMigrationRecord  WHERE DataMigrationClass LIKE '%%'

4: From the search results above, make a note of the Id values of rows in these tables.

Orchard_Framework_ContentTypeRecord.Id
Settings_ContentTypeDefinitionRecord.Id 

5: Now that you have recorded Id, delete the rows that you found in step 3 above.

6: Using the Ids collected in step 4, delete the rows from the following tables.

SELECT * FROM Settings_ContentTypePartDefinitionRecord 
    WHERE ContentTypeDefinitionRecord_Id IN()

SELECT * FROM Orchard_Framework_ContentItemRecord 
    WHERE ContentType_id IN ()

That's what worked for me.

like image 110
Shaun Luttin Avatar answered Oct 28 '22 15:10

Shaun Luttin


I don’t know if there is a proper way to do that, but cleaning up Orchard_Framework_DataMigrationRecord should be enough: datamigration checks this table to find the current feature version, if there is already an entry you may not be able to re-enable the feature. Also check Settings_ShellFeatureRecord, Settings_ShellFeatureStateRecord, Settings_ContentPartDefinitionRecord and Settings_ContentTypeDefinitionRecord.

Finally, there may be many references in other tables but I think nothing dangerous.

like image 29
fg_garda Avatar answered Oct 28 '22 16:10

fg_garda