I don’t know what the problem was.
pg_dump and restoring seems to have fixed it. I then re-ran bundle exec rake db:migrate.