Fix faulty migration on postgresql
Fix unit tests for changed generate_ticket_granting_ticket