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

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

# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class AddNameToGeoNodes < ActiveRecord::Migration[5.0]
  include Gitlab::Database::MigrationHelpers

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  def up
    add_column :geo_nodes, :name, :string # rubocop:disable Migration/PreventStrings

    # url is also unique, and its type and size is identical to the name column,
    # so this is safe.
    execute "UPDATE geo_nodes SET name = url;"

    # url is also `null: false`, so this is safe.
    change_column :geo_nodes, :name, :string, null: false
  end

  def down
    remove_column :geo_nodes, :name
  end
end