Modify db to handle permission in a more flexible way

Linked to pull request in clicker-api.