Behaviour of rake db:prepare in environments where database is pre-created

I am one of the contributors to an open-source rails project called chatwoot. As a part of the project set up / upgrade instructions, we recommend users to run rake db:prepare, which works for the most parts.

But in environments like Heroku, the database comes pre-created. Where db:prepare will attempt to run migrations right from the start, instead of running schema:load, which leads to issues since some of the underlying data models referred to in these migrations have changed as the codebase has evolved.

Right now, we are getting around this with a modified version of the original db:prepare function around

Along with the check for the existence of the database, we also check for the presence of ar_internal_metadata table ( or possibly schema_migrations ) before deciding whether to run schema:load instead of db:migrate.

Could there be any pitfalls to this approach? Also, would it make sense to add the same check to the rails core?