Class: CreateDuctworkBranchLinks
- Inherits:
-
Ductwork::Migration
- Object
- Ductwork::Migration
- CreateDuctworkBranchLinks
- Defined in:
- lib/generators/ductwork/update/templates/db/create_ductwork_branch_links.rb,
lib/generators/ductwork/install/templates/db/create_ductwork_branch_links.rb
Instance Method Summary collapse
Methods included from Ductwork::MigrationHelper
#belongs_to, #create_ductwork_table, #mysql?, #postgresql?, #uuid_column_type
Instance Method Details
#change ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/ductwork/update/templates/db/create_ductwork_branch_links.rb', line 4 def change create_ductwork_table :ductwork_branch_links do |table| belongs_to( table, :parent_branch, index: true, null: false, foreign_key: { to_table: :ductwork_branches } ) belongs_to( table, :child_branch, index: true, null: false, foreign_key: { to_table: :ductwork_branches } ) table. null: false end add_index :ductwork_branch_links, %w[parent_branch_id child_branch_id], unique: true end |