Create a SelfJoin has_many

I am trying to do a Self-join and I generate this migration to make a
correct primary, I’m not sure if this is really right. There is some
problem here?

class CreateFeedstocks < ActiveRecord::Migration[5.0]
def change
create_table :feedstocks do |t|
t.string :code
t.float :measure_one
t.float :measure_two
t.float :measure_three
t.string :description
t.integer :primary_feedstock_id, index: true

add_foreign_key :feedstocks, :feedstocks, column:

:primary_feedstock_id, primary_key: :id

One feedstock has one primary_feedstock and one primary_feedstock has
many feedstocks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs