summaryrefslogtreecommitdiff
path: root/db/migrate/20200206112850_create_snippet_repository_table.rb
blob: 0c14b37855d5ee1053fdf6477f187b61f083339b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
# frozen_string_literal: true

class CreateSnippetRepositoryTable < ActiveRecord::Migration[6.0]
  DOWNTIME = false

  def change
    create_table :snippet_repositories, id: false, primary_key: :snippet_id do |t|
      t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict }
      t.references :snippet, primary_key: true, default: nil, index: false, foreign_key: { on_delete: :cascade }
      t.string :disk_path, limit: 80, null: false, index: { unique: true }
    end
  end
end