Fixes for migration on PostgreSQL