fix database constraints