Sha256: 3f2ea58dea73d722e4bf6a2b2cb9bca8ab0eda24fbb56aff454b862aef9a10e8

Contents?: true

Size: 1.32 KB

Versions: 9

Compression:

Stored size: 1.32 KB

Contents

class AddForeignKeyConstraints < ActiveRecord::Migration
  def change
    # user foreign keys
    add_foreign_key :concepts, :users, column: 'locked_by', on_delete: :nullify, on_update: :cascade
    add_foreign_key :exports, :users, column: 'user_id', on_delete: :nullify, on_update: :cascade
    add_foreign_key :imports, :users, column: 'user_id', on_delete: :nullify, on_update: :cascade

    # concept/collection foreign keys
    add_foreign_key :concept_relations, :concepts, column: 'owner_id', on_update: :cascade
    add_foreign_key :concept_relations, :concepts, column: 'target_id', on_update: :cascade
    add_foreign_key :collection_members, :concepts, column: 'collection_id', on_update: :cascade
    add_foreign_key :collection_members, :concepts, column: 'target_id', on_update: :cascade
    add_foreign_key :labelings, :concepts, column: 'owner_id', on_update: :cascade
    add_foreign_key :matches, :concepts, column: 'concept_id', on_delete: :cascade, on_update: :cascade
    add_foreign_key :notations, :concepts, column: 'concept_id', on_update: :cascade

    # labels
    add_foreign_key :labelings, :labels, column: 'target_id',  on_delete: :cascade, on_update: :cascade

    # note annotations foreign keys
    add_foreign_key :note_annotations, :notes, column: 'note_id', on_delete: :cascade, on_update: :cascade
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
iqvoc-4.12.1 db/migrate/20141204151558_add_foreign_key_constraints.rb
iqvoc-4.12.0 db/migrate/20141204151558_add_foreign_key_constraints.rb
iqvoc-4.11.1 db/migrate/20141204151558_add_foreign_key_constraints.rb
iqvoc-4.11.0 db/migrate/20141204151558_add_foreign_key_constraints.rb
iqvoc-4.10.0 db/migrate/20141204151558_add_foreign_key_constraints.rb
iqvoc-4.9.0 db/migrate/20141204151558_add_foreign_key_constraints.rb
iqvoc-4.8.2 db/migrate/20141204151558_add_foreign_key_constraints.rb
iqvoc-4.8.1 db/migrate/20141204151558_add_foreign_key_constraints.rb
iqvoc-4.8.0 db/migrate/20141204151558_add_foreign_key_constraints.rb