Prevent double-migration via attachment-checking
Prevent double-migration via attachment-checking

This uses the existence of a heroku-postgres plan that has the same
URL as SHARED_DATABASE_URL as convincing evidence that no migration is
necessary.  However, there are some corner cases:

* If a user has their own non-heroku-postgres resource URL bound to
  SHARED_DATABASE_URL (why? why not?) then this code will decide that
  this database does need to be migrated rather than saying "this is
  not a legacy database, and so no migration is unnecessary"

* If a user points SHARED_DATABASE_URL at a URL that is not attached
  to that app -- such as in the case of database sharing -- then
  again, this code will fail to detect that no migration is necessary.

In these two cases, this approach cannot detect every case where
migration is unnecessary, but it will never incorrectly fail to
perform a migration when it is.

However, in one other case, it is possible to miss a migration: if the
user decided, for whatever reason, to remove the SHARED_DATABASE_URL
variable from their application and re-add it under a different name,
then no migration requirement would be detected.

Signed-off-by: Dan Farina <bee449cdf8304c08319f4f5bbfe9582c670af7b4@acm.org>

heroku/heroku-pgmigrate