random returns a random decimal between 0 and 1. You can multiply and round the result to get a number as you need it.
What about:
round(random()*899999)+100000)
For the unique you have to add a logic, that checks, if your new generated number already exists. Maybe you retrieve your generated numbers from the entity and see, if your return is ‘empty’. If true, go ahead, if false, try again. ;-)