Custom database functions

Thanks @Justin_Sherrill, I have added PRs for that:

Looks like I am still missing something in https://github.com/Katello/katello/pull/8708#issuecomment-628670878

Looks like the db/schema.rb is not created successfully