Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20210222192144_remove_backup_labels_table.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1208c3c970fef6181cf0518bf4293cdd5d76f07c (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
# frozen_string_literal: true

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

  def up
    drop_table :backup_labels
  end

  def down
    create_table :backup_labels, id: false do |t|
      t.integer :id, null: false
      t.string :title
      t.string :color
      t.integer :project_id
      t.timestamps null: true # rubocop:disable Migration/Timestamps
      t.boolean :template, default: false
      t.string :description
      t.text :description_html
      t.string :type
      t.integer :group_id
      t.integer :cached_markdown_version
      t.integer :restore_action
      t.string :new_title
    end

    execute 'ALTER TABLE backup_labels ADD PRIMARY KEY (id)'

    add_index :backup_labels, [:group_id, :project_id, :title], name: 'backup_labels_group_id_project_id_title_idx', unique: true
    add_index :backup_labels, [:group_id, :title], where: 'project_id = NULL::integer', name: 'backup_labels_group_id_title_idx'
    add_index :backup_labels, :project_id, name: 'backup_labels_project_id_idx'
    add_index :backup_labels, :template, name: 'backup_labels_template_idx', where: 'template'
    add_index :backup_labels, :title, name: 'backup_labels_title_idx'
    add_index :backup_labels, [:type, :project_id], name: 'backup_labels_type_project_id_idx'
  end
end