Add a random number to the file's name let it be the unique one in the database

Just wondering out loud here…: would using the smart rule with Bates numbering (see DEVONthink 3.5 Documentation, page 81) not make your file names unique?

Bates numbering should indeed be a sufficient.

I never used Bates numbering. Would this approach result in names from 1 to the count of children?

No. Bates numbering is an continuously incrementing unique number, i.e., subsequent uses will continue incrementing, not start again at 0 or 1.