The timestamp that’s passed to version in db/schema.rb is very important to get right, especially in merges.

It says “this is what the database looked like after all the migrations up to the file with the same timestamp as this”

ActiveRecord::Schema.define(version: 2023_07_02_163352) do

When I did some squashing of commits, I put an index into schema, but didn’t change the version number to match the migration file that did that.

Heroku CI runs rails db:schema:load and then any migrations that haven’t been run, but it only knows what ‘hasn’t been run’ by that timestamp, so it tried to index a column that had already been indexed.

Changing it to the above, which matched the timestamp on the index migration file (20230702163352_add_index_to_estimate_item_total.rb), fixed the problems.

Just worth remembering that most of our environments start with db:schema:load, not migrate (and you should too when checking out a new project!).

John Norris


Who are Dragon Drop?

Dragon Drop is a specialist web and app development agency. The team has extensive full-stack technical credentials and a strong focus on user experience.

The Dragon Drop founding team have over 40 years of web development and project experience. They have managed or developed over 100 significant ecommerce and web projects during their careers, including implementations for major UK high street retailers, financial services companies and government agencies.

Their approach to innovative solutions stems from perspectives gained as retailer, software supplier and web agency.