
josue rodrigo fierro morfin
Pregunta**me aroja este error **
== 20210419164846 CreateParticipants: migrating ===============================
– create_table(:participants)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
you can’t define an already defined column ‘task_id’.
/home/kowel/organisador/db/migrate/20210419164846_create_participants.rb:7:in
block in change' /home/kowel/organisador/db/migrate/20210419164846_create_participants.rb:3:in
/home/kowel/organisador/bin/rails:5:in
<top (required)>' /home/kowel/organisador/bin/spring:10:in
/home/kowel/organisador/bin/spring:7:in `<top (required)>’
Caused by:
ArgumentError: you can’t define an already defined column ‘task_id’.
/home/kowel/organisador/db/migrate/20210419164846_create_participants.rb:7:in
block in change' /home/kowel/organisador/db/migrate/20210419164846_create_participants.rb:3:in
/home/kowel/organisador/bin/rails:5:in
<top (required)>' /home/kowel/organisador/bin/spring:10:in
/home/kowel/organisador/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Johan Tique
Hola Josue, podrías por favor mostrarme el contenido de la migración con la que estás creando la tabla
20210419164846_create_participants.rb

josue rodrigo fierro morfin
class CreateParticipants < ActiveRecord::Migration[6.1] def change create_table :participants do |t| t.integer :role t.references :user, null: false, foreign_key: true t.references :task, null: false, foreign_key: true t.references :task, null: false, foreign_key: true t.timestamps end end end

Johan Tique
el error te menciona "you can’t define an already defined column ‘task_id’." por lo que debes encontrar la razón por la cual se está re-definiendo la llave foránea, cuando revises tu migración veras la siguiente línea duplicada
t.references :task, null:false, foreign_key:true
task_id