Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Add index for ruby 3.0 #78

Merged
merged 1 commit into from Sep 6, 2022

Conversation

MaximeRVY
Copy link

Hello there,

We detected there is an error when we use ruby 3.0 and ActiveRecord 6.0

CF error:

StatementInsurerTest#test_add_belongs_to:
StandardError: An error has occurred, all later migrations canceled:

wrong number of arguments (given 3, expected 2)
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/lib/safe-pg-migrations/plugins/statement_insurer.rb:67:in `add_index'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/lib/safe-pg-migrations/plugins/useless_statements_logger.rb:15:in `add_index'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/connection_adapters/abstract/schema_definitions.rb:570:in `index'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/connection_adapters/abstract/schema_definitions.rb:152:in `add_to'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:905:in `add_reference'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:890:in `block in method_missing'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:858:in `block in say_with_time'
    /opt/hostedtoolcache/Ruby/3.0.4/x64/lib/ruby/3.0.0/benchmark.rb:293:in `measure'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:858:in `say_with_time'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:879:in `method_missing'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/lib/safe-pg-migrations/base.rb:102:in `block (2 levels) in <module:Migration>'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/test/statement_insurer_test.rb:116:in `change'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:828:in `exec_migration'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/lib/safe-pg-migrations/base.rb:81:in `block in exec_migration'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/lib/safe-pg-migrations/base.rb:34:in `block in setup_and_teardown'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/lib/safe-pg-migrations/plugins/statement_insurer.rb:100:in `with_setting'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/lib/safe-pg-migrations/base.rb:34:in `setup_and_teardown'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/lib/safe-pg-migrations/base.rb:80:in `exec_migration'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
    /opt/hostedtoolcache/Ruby/3.0.4/x64/lib/ruby/3.0.0/benchmark.rb:293:in `measure'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:811:in `block in migrate'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:810:in `migrate'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:1363:in `ddl_transaction'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:[128](https://github.com/qonto/safe-pg-migrations/runs/8031200189?check_suite_focus=true#step:5:129)1:in `block in migrate_without_lock'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:1280:in `each'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:1280:in `migrate_without_lock'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:1229:in `block in migrate'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:[138](https://github.com/qonto/safe-pg-migrations/runs/8031200189?check_suite_focus=true#step:5:139)2:in `with_advisory_lock'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/vendor/bundle/ruby/3.0.0/gems/activerecord-6.0.5.1/lib/active_record/migration.rb:1229:in `migrate'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/test/test_helper.rb:58:in `run_migration'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/test/statement_insurer_test.rb:120:in `block in test_add_belongs_to'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/test/test_helper.rb:118:in `record_calls'
    /home/runner/work/safe-pg-migrations/safe-pg-migrations/test/statement_insurer_test.rb:120:in `test_add_belongs_to'

So we made this tiny fix

@ThHareau
Copy link
Contributor

ThHareau commented Sep 6, 2022

Hey Maxime, thanks for finding this :)

@ThHareau ThHareau merged commit 64c616a into doctolib:master Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants