summaryrefslogtreecommitdiff
path: root/db/migrate/20191004133612_create_analytics_repository_file_commits.rb
blob: f2064b2b301ecf4877296a6bc97722cd0912a7a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

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

  def change
    create_table :analytics_repository_file_commits do |t|
      t.references :analytics_repository_file, index: { name: 'index_analytics_repository_file_commits_file_id' }, foreign_key: { on_delete: :cascade }, null: false
      t.references :project, index: false, foreign_key: { on_delete: :cascade }, null: false
      t.date :committed_date, null: false
      t.integer :commit_count, limit: 2, null: false
    end

    add_index :analytics_repository_file_commits,
      [:project_id, :committed_date, :analytics_repository_file_id],
      name: 'index_file_commits_on_committed_date_file_id_and_project_id',
      unique: true
  end
end