postgres: fix PK drop, don't assume PK name as TABLE_pkey

When dropping a primary key, postgres requires the primary key name to
be specified.  In the UpdatePrimaryKeys init step it was assumed that
the primary key name for a table X is always X_pkey. However, since the
Schema_82 this pattern doesn't hold for those tables which were renamed
in that migration, as the migration only renamed the tables. For
example, before Schema_82 we had a table name:

  account_group_includes_by_uuid_audit

and its primary key named:

  account_group_includes_by_uuid_audit_pkey

This table was renamed to:

  account_group_by_id_aud

but the primary key name didn't change. Therefore, the UpdatePrimaryKeys
failed to drop the primary key using the TABLE_pkey pattern and couldn't
then create the new primary key.

Instead of assuming the TABLE_pkey pattern get the old primary key
name from the DatabaseMetaData and use this name for dropping the
existing primary key.

Change-Id: I671b9912110fc22c842d2c15930a2c7b9906bd48
1 file changed