I'm making a plugin that stores elements in fields and fieldGroups. When deleting one the elements with the fields/field groups are being removed too.
But when deleting the whole plugin, those fields are still in the database. When reinstalling the plugin this makes it impossible to add the field with the same title again.
I've already added 'onDelete' things in all the records like this:
public function defineRelations()
{
return array(
'form' => array(static::BELONGS_TO, 'PluginHandle_FormRecord', 'onDelete' => static::CASCADE),
'fieldGroup' => array(static::BELONGS_TO, 'FieldGroupRecord', 'onDelete' => static::CASCADE),
'field' => array(static::BELONGS_TO, 'FieldRecord', 'onDelete' => static::CASCADE)
);
}
I've been searching the docs to see what actually happens when a plugin is being deleted, but can't find anything. Any ideas?