Added to the entity_permissions table with further required fields and indexes. Wrote the code for checking permissions.