20191121121947_create_packages_dependency_links.rb 698 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

class CreatePackagesDependencyLinks < ActiveRecord::Migration[5.2]
  DOWNTIME = false

  def change
    create_table :packages_dependency_links do |t|
      t.references :package, index: false, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint
      t.references :dependency, null: false, foreign_key: { to_table: :packages_dependencies, on_delete: :cascade }, type: :bigint
      t.integer :dependency_type, limit: 2, null: false
    end

    add_index :packages_dependency_links, [:package_id, :dependency_id, :dependency_type], unique: true, name: 'idx_pkgs_dep_links_on_pkg_id_dependency_id_dependency_type'
  end
end