summaryrefslogtreecommitdiff
path: root/db/migrate/20200813135558_create_ci_deleted_objects.rb
blob: 5364b7fc0ce91dec498f2a60bdd78fdfb2d59525 (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
# frozen_string_literal: true

class CreateCiDeletedObjects < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    create_table :ci_deleted_objects, if_not_exists: true do |t|
      t.integer :file_store, limit: 2, default: 1, null: false
      t.datetime_with_timezone :pick_up_at, null: false, default: -> { 'now()' }, index: true
      t.text :store_dir, null: false

      # rubocop:disable Migration/AddLimitToTextColumns
      # This column depends on the `file` column from `ci_job_artifacts` table
      # which doesn't have a constraint limit on it.
      t.text :file, null: false
      # rubocop:enable Migration/AddLimitToTextColumns
    end

    add_text_limit(:ci_deleted_objects, :store_dir, 1024)
  end

  def down
    drop_table :ci_deleted_objects
  end
end