summaryrefslogtreecommitdiff
path: root/db/migrate/20201204111400_create_packages_debian_project_component_files.rb
blob: 74ee1e9c4cf3a7aaa239f474964e27f58f5b953b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true

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

  DOWNTIME = false

  INDEX_ARCHITECTURE = 'idx_packages_debian_project_component_files_on_architecture_id'

  disable_ddl_transaction!

  def up
    with_lock_retries do
      unless table_exists?(:packages_debian_project_component_files)
        create_table :packages_debian_project_component_files do |t|
          t.timestamps_with_timezone
          t.references :component,
            foreign_key: { to_table: :packages_debian_project_components, on_delete: :restrict },
            null: false,
            index: true
          t.references :architecture,
            foreign_key: { to_table: :packages_debian_project_architectures, on_delete: :restrict },
            index: { name: INDEX_ARCHITECTURE }
          t.integer :size, null: false
          t.integer :file_type, limit: 2, null: false
          t.integer :compression_type, limit: 2
          t.integer :file_store, limit: 2, default: 1, null: false
          t.text :file, null: false
          t.binary :file_md5, null: false
          t.binary :file_sha256, null: false
        end
      end
    end

    add_text_limit :packages_debian_project_component_files, :file, 255
  end

  def down
    drop_table :packages_debian_project_component_files
  end
end