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

Cannot run "rake db:migrate" #1287

Closed
3 tasks done
tomozip opened this issue Jan 8, 2021 · 2 comments · Fixed by #1298
Closed
3 tasks done

Cannot run "rake db:migrate" #1287

tomozip opened this issue Jan 8, 2021 · 2 comments · Fixed by #1298

Comments

@tomozip
Copy link

tomozip commented Jan 8, 2021

Thank you for your contribution!

Due to limited volunteers, issues that do not follow these instructions will be
closed without comment.

Check the following boxes:

  • This is not a usage question, this is a bug report
  • This bug can be reproduced with the script I provide below
  • This bug can be reproduced in the latest release of the paper_trail gem

My Env

  • Ruby version: 3.0.0
paper_trail (11.1.0)
  activerecord (>= 5.2)
  request_store (~> 1.1)

Bug

Today, I act like this.

  1. add this gem to Gemfile
  2. $ bundle install
  3. $ bundle exec rails generate paper_trail:install
  4. $ bundle exec rake db:migrate → I've got Error.

Error log bellow.

== 20210108081414 CreateVersions: migrating ===================================
-- create_table(:versions, {:options=>"ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

wrong number of arguments (given 2, expected 1)
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/connection_adapters/mysql/schema_statements.rb:80:in `create_table'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:929:in `block in method_missing'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:897:in `block in say_with_time'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:897:in `say_with_time'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:918:in `method_missing'
myapp/db/migrate/20210108081414_create_versions.rb:12:in `change'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:867:in `exec_migration'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:851:in `block (2 levels) in migrate'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:850:in `block in migrate'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in `with_connection'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:849:in `migrate'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1037:in `migrate'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1329:in `block in execute_migration_in_transaction'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1382:in `ddl_transaction'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1328:in `execute_migration_in_transaction'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1302:in `each'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1302:in `migrate_without_lock'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1251:in `block in migrate'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1401:in `block in with_advisory_lock'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1416:in `block in with_advisory_lock_connection'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:462:in `with_connection'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1416:in `with_advisory_lock_connection'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1397:in `with_advisory_lock'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1251:in `migrate'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1086:in `up'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/migration.rb:1061:in `migrate'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/railties/databases.rake:90:in `each'
myapp/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.0/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
myapp/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/Users/tomozip/.rbenv/versions/3.0.0/bin/bundle:23:in `load'
/Users/tomozip/.rbenv/versions/3.0.0/bin/bundle:23:in `<main>'

My fix

I Fix db/migrate/20210108081414_create_versions.rb:12.

Before

class CreateVersions < ActiveRecord::Migration[6.1]
...
  def change
    create_table :versions, { options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" } do |t|
      t.string   :item_type, {:null=>false, :limit=>191}
      ...

After

class CreateVersions < ActiveRecord::Migration[6.1]
...
  def change
    create_table :versions, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" do |t|
      t.string   :item_type, {:null=>false, :limit=>191}
      ...

After that, I can run $ bundle exec rake db:migrate.
It works for me!

I think this bug is about Ruby3.0.0.
Thank you.

@tlynam
Copy link
Contributor

tlynam commented Jan 18, 2021

Hi @tomozip! Thank you for submitting this! Which version of Rails are you using? I'm not able to create a new Rails app in Rails 5.2 with Ruby 3. I wasn't able to reproduce the issue in Rails 6.1.1. I found this compatibility table if it helps:
https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html

@jaredbeck
Copy link
Member

The options in question are MySQL specific. I was able to reproduce this issue in ruby 3.0, rails 6.1, with adapter: mysql2 in my config/database.yml. This should be an easy fix, inPaperTrail::InstallGenerator#versions_table_options. PRs welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants