Modified view-related migrations so that views are dropped in the
proper order (views depending on other views are dropped first).
Modified 'group by' clauses to be compatible with PostgreSQL's stricter requirements.