Regenerating slugs for subset of data

Skip to first unread message

Mathieu Deschaine

Jul 26, 2019, 12:50:36 PM7/26/19
to AtoM Users
Hello All,

We're in the middle of doing an audit of the Authority Records on our site, and I was wondering if there was a way to delete/regenerate the slugs for only specific entities (like Actors/Authority records).

There is a generate slugs command and a list of what it effects, and the --delete option, but no options for specifying entities.  
It looks like there may be a way to do this with SQL, but doing that for each individual slug seems pretty cumbersome, and I'm a bit wary of direct database changes in general.

Mathieu Deschaine

Dan Gillean

Jul 26, 2019, 2:30:13 PM7/26/19
to ICA-AtoM Users
Hi Mathieu, 

Unfortunately at this time, other than the --delete option, there are no further configuration options available for the generate-slugs task. Using SQL is likely the only way to go at present. 

I have tested out this query in my local test instance and it seems to work well. However as always, proceed at your own risk, and I strongly recommend you make a backup of your data before proceeding, just in case! 

You can run it as a SELECT first, to review the slugs listed, and to check the count against the number of authority records you have to make sure that nothing else is being pulled in: 
  • SELECT slug FROM slug INNER JOIN actor ON = slug.object_id INNER JOIN object o ON WHERE o.class_name='QubitActor' AND actor.parent_id IS NOT NULL;
Some notes on this, so you know what it's doing:
  • The actor table is also used by user accounts and repository records. By joining on the object table and using the WHERE clause to limit it to those entities that have a class of QubitActor, we are ensuring that only authorities are affected
  • the actor.parent_id IS NOT NULL at the end is to ensure that we don't delete the root actor record's slug - all other actors have this actor's ID listed as the parent ID in the database. 
If the output of the select looks good and matches your count of authorities, then you can run the same query again as a DELETE rather than a SELECT: 
  • DELETE slug FROM slug INNER JOIN actor ON = slug.object_id INNER JOIN object o ON WHERE o.class_name='QubitActor' AND actor.parent_id IS NOT NULL;
You can then use the slug generation task - don't use the --delete option, as we have already deleted the slugs we want to update! If you do, AtoM will delete ALL slugs and replace them. 
  • php symfony propel:generate-slugs
Remember that after running the task, you'll want to rebuild the search index: 
  • php symfony search:populate
You may want to clear your caches as well to ensure they are up to date. Commands for PHP 7.2 in Ubuntu 18.04: 
  • php symfony cc
  • sudosystemctl restart php7.2-fpm

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.

You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages