I want to automatically detect if I need to run heroku run rake db:migration after I have deployed a new release. If I find no migration is needed, then there is no need to put the live site into maintenance mode.
One approach would be a ruby script file that would run system("run rake db:version") to find current version, then examine the timestamp part of the files in db/migrate to find the latest version and do a db:migrate if the current version is older than the most recent timestamp in the db/migrate directory.
However this feels brittle, is there a more robust way?