Issue when deleting Assets and recreating with roles

I experienced a bug with the Asset extension. When you find assets by name,
when you press the bulk update button and change one value, the name of the
search gets assigned to all assets.

Having found this, i wanted to delete all assets and reinsert them. So i
changed their status to deleted and tried again but got an error with the
asset import csv extension.

So then i did a very foolish thing, and went over mysql and deleted the
assets i wanted from the RTxAssets table.

When i want to import them again, i now get all kinds of errors regarding
roles:

[30097] [Thu Oct 16 18:33:17 2014] [error]: Couldn’t create role groups for
asset 14504 (/opt/rt4/local/plugins/RT-Extension-Assets/lib/RT/Asset.pm:275)
[30097] [Thu Oct 16 18:33:17 2014] [error]: Failed to create asset for row
303: Couldn’t create role groups for asset
(/opt/rt4/local/plugins/RT-Extension-Assets-Import-CSV/lib/RT/Extension/Assets/Import/CSV.pm:224)
[30460] [Thu Oct 16 18:36:53 2014] [error]: Couldn’t create a role group of
type ‘Owner’ for RT::Asset 18517: Role group exists already
(/opt/rt4/lib/RT/Record/Role/Roles.pm:588)

So i guess that means i need to delete those roles manually as well, but i
haven’t been able to find the table for that. Can someone give me a hint?

View this message in context: http://requesttracker.8502.n7.nabble.com/Issue-when-deleting-Assets-and-recreating-with-roles-tp58863.html

I experienced a bug with the Asset extension. When you find assets by name,
when you press the bulk update button and change one value, the name of the
search gets assigned to all assets.

Please explain more clearly what you mean by “the name of the search”.
We do like to have good bug reports on issues like this.

Having found this, i wanted to delete all assets and reinsert them. So i
changed their status to deleted and tried again but got an error with the
asset import csv extension.

Please give the error.

So then i did a very foolish thing, and went over mysql and deleted the
assets i wanted from the RTxAssets table.

Doing things like that puts you solidly in “good luck” territory, and
vastly decreases our ability or impetus to help you. I strongly suggest
you copy over a new snapshot of production onto your development server
and start there – assuming, of course, that this was in development and
you weren’t running random DELETE statements on your production server,
riiiiight?

When i want to import them again, i now get all kinds of errors regarding
roles:

[30097] [Thu Oct 16 18:33:17 2014] [error]: Couldn’t create role groups for
asset 14504 (/opt/rt4/local/plugins/RT-Extension-Assets/lib/RT/Asset.pm:275)
[30097] [Thu Oct 16 18:33:17 2014] [error]: Failed to create asset for row
303: Couldn’t create role groups for asset
(/opt/rt4/local/plugins/RT-Extension-Assets-Import-CSV/lib/RT/Extension/Assets/Import/CSV.pm:224)
[30460] [Thu Oct 16 18:36:53 2014] [error]: Couldn’t create a role group of
type ‘Owner’ for RT::Asset 18517: Role group exists already
(/opt/rt4/lib/RT/Record/Role/Roles.pm:588)

So i guess that means i need to delete those roles manually as well, but i
haven’t been able to find the table for that. Can someone give me a hint?

Assuming you deleted assets 1, 2, and 3:

DELETE FROM Groups
WHERE Domain = ‘RT::Asset-Role’
AND Instance IN (1, 2, 3);

DELETE FROM ObjectCustomFieldValues
WHERE ObjectType = ‘RT::Asset’
AND ObjectId IN (1, 2, 3);

DELETE FROM Transactions
WHERE ObjectType = ‘RT::Asset’
AND ObjectId IN (1, 2, 3);

…there may well be others, those are the minimums that occur to me of
the top of my head. I suggest you heed the earlier advice and start afresh.

  • Alex

Sorry, i will try to explain myself further. English is not my primary
language.

We user a number to identify our assets (with some exceptions that gives me
trouble). To better classify our assets, we use the format
device-location-id, so i am able to search only printers for example,
without needing a custom field (which in reality i also am using).

So i search for “imp-mar” which gives me all printers in our MAR branch.
That gives me imp-mar-18273, imp-mar-37293…
Suppose i want to update the custom field that holds the printer’s location.
Since the import won’t magically associate MAR with “Oficina Principal”, i
search for all imp-mar assets and then just update the custom field with a
bulk update.

The issue i experienced is the following:

Step 1: search for “imp-mar”
Step 2: press “bulk update”
Step 3: change the custom field

Result: all assets with imp-mar in its name gets renamed to imp-mar, losing
the number, unless i remember to delete the “name” field with the search i
just did.
Changing the status of the asset to “deleted” just hides the assets, but
doesn’t delete them from the database! Therefore i went to the manual
route…

If you want me to file a bug i will happily do so.

I don’t have a production server, i just have my development server and
hoping to promote to production once i finish some issues. That means i
haven’t made a recurring backup just yet. But the three tables you mentioned
actually were the one i needed, so i did the following.

-Installed phpmyadmin
-Created a new table with one column, and imported a csv with just that one
column, containing the id’s of the assets i wanted to prune off the
database.
-delete from Groups where domain like ‘%Asset%’ and instance in (select
activo from activo);
-delete from ObjectCustomFieldValues where ObjectType like ‘%Asset%’ and
ObjectId in (select activo from activo);
-delete from Transactions where ObjectType like ‘%Asset%’ and ObjectId in
(select activo from activo);

Thanks!!

View this message in context: http://requesttracker.8502.n7.nabble.com/Issue-when-deleting-Assets-and-recreating-with-roles-tp58863p58865.html