Developer forum

Forum » CMS - Standard features » Delete ItemType instances - that are not attached to a Page or Paragraph - from database

Delete ItemType instances - that are not attached to a Page or Paragraph - from database

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

On one of our solutions, it appears that there are ItemType instances that are not attached to any page or paragraph. So just the ItemType appears in the database, but no relation to any page/paragraph. These ItemTypes have only ever been available to create as pages, so they should belong to a page - but that does´nt seem to be the case.

Don´t know how this has happened, but this is interrupting when trobuleshooting, and therefore - we want to delete the item instances that don´t have a page relation.

Can this be done? And if so - how?

 

/Hans


Replies

 
Nicolai Pedersen
Reply

You can do a number of things

  • Delete the item type from item type management if they are still there. It also has a usage report.
  • If you have no item type definition for the table, you can run "DROP Itemtype_{systemname}" from sql firehose under settings
  • If you want to remove the records only, you can do "DELETE FROM Itemtype_{systemname} from sql firehose under settings

BR Nicolai

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

we still use the ItemType, and it has lots of instances - so we only want to delete the ones that don´t have a pagerelation. Is there any pagerelation column on the ItemType? If so, what is it called? How can i - via SQL - find only the itemType records that don´t have a page relation?

 

/Hans

 
Nicolai Pedersen
Reply

Hi Hans

Try this first one (or something like that to see items not in use)

select itemtype_{systemname} where itemid not in (select itemid from page where itemname = 'systemname')

And this to delete

delete from itemtype_{systemname} where itemid not in (select itemid from page where itemname = 'systemname')

They are not tested...

 

You must be logged in to post in the forum