Regenerate Asset Tags

Though this is likely not something that would be necessary in most cases, Snipe-IT provides a command-line tool that allows you to regenerate all of your asset tags.

❗️

Important

This action is data destructive. It will permanently overwrite all of your asset tags and cannot be undone.

From the Snipe-IT project root, via command line, run:

php artisan snipeit:regenerate-tags
OptionNoteType
--start=Override the next auto-increment in Admin > Asset Tags with this numeric value.Numeric value
--output=Display output.Options are info, warn, error, or all.

After the asset tags are regenerated, you'll want to update your Admin > Asset Tags next auto increment setting.

If you ONLY need to reset the zero fill on your asset tags, (for example to transition from 00035 to 000000035) but need the asset tags otherwise unchanged, you can run the following, AFTER completing a backup of your database:

UPDATE assets SET `asset_tag`=LPAD(`asset_tag`, 9, '0');

where 9 is the width of the new zero filled number.

To preview what would change without actually updating the asset_tags, you can run:

SELECT asset_tag,LPAD(`asset_tag`, 9, '0') from assets WHERE asset_tag != LPAD(`asset_tag`, 9, '0');

If you wanted to renumber all of your asset tags based off of the ID, for example, you want all of your asset tags to be 9 digits, zero-filled, but it should use the ID of the asset row in the database as the basis, you could do something like this:

UPDATE assets SET asset_tag = LPAD(`id`,9,'0');