Closed
Description
I'm trying to upgrade the rails 5.2
to 6.1
. All migrations works fine on 5.2, but I started to receive this error on 6.1
Steps to reproduce
In my case, i'm using the postgres 9 but I tested in a new project with SQLite and has the same issue
- Create a new project with rails 6/7
- Create a new migration
- Add the code below:
- Run
rails db:migrate
class Test < ActiveRecord::Migration[6.1]
def change
create_table :question_options, id: false do |t|
t.string :label, null: false
end
create_table :answers, id: false do |t|
t.string :question_option_id
end
create_join_table :question_options, :answers do |t|
t.references :question_option, foreign_key: true, null: false, index: { name: :question_option_id}
t.references :answer, foreign_key: true, null: false, index: {name: :answer_id}
end
end
end
Expected behavior
Run the migration without errors
Actual behavior
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
you can't define an already defined column 'question_option_id'.
System configuration
Rails version: 6.1.7.1
Ruby version: 2.7.6