Tell Rails what migration versions are already runned

Edit
equivalent Web Development
Public
Rails
migrations

Sometimes you mess up branch db migrations and Rails point to wrong migration version . You can fix it by  adding value to version table 

e.g. db/migrate/20250624142359_create_users.rb

ActiveRecord::Base.connection.execute("INSERT INTO schema_migrations (version) VALUES ('20250624142359')")

to add multiple:


['20250521091159',
'20250522115839',
'20250527123030',
'20250624081647',
'20250624101403'].each do |version|
  ActiveRecord::Base.connection.execute("INSERT INTO schema_migrations (version) VALUES (#{version})")
end