summaryrefslogtreecommitdiff
path: root/db/migrate/20191016133352_create_ci_subscriptions_projects.rb
blob: 00ab2c19193b1d169e4a4fb417ef735c815b4d31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class CreateCiSubscriptionsProjects < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  def change
    create_table :ci_subscriptions_projects do |t|
      t.references :downstream_project, null: false, index: false, foreign_key: { to_table: :projects, on_delete: :cascade }
      t.references :upstream_project, null: false, foreign_key: { to_table: :projects, on_delete: :cascade }
    end

    add_index :ci_subscriptions_projects, [:downstream_project_id, :upstream_project_id],
      unique: true, name: 'index_ci_subscriptions_projects_unique_subscription'
  end
end