summaryrefslogtreecommitdiff
path: root/db/migrate/20190409224933_add_name_to_geo_nodes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20190409224933_add_name_to_geo_nodes.rb')
-rw-r--r--db/migrate/20190409224933_add_name_to_geo_nodes.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/db/migrate/20190409224933_add_name_to_geo_nodes.rb b/db/migrate/20190409224933_add_name_to_geo_nodes.rb
new file mode 100644
index 00000000000..2dff81b429c
--- /dev/null
+++ b/db/migrate/20190409224933_add_name_to_geo_nodes.rb
@@ -0,0 +1,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
+
+ # 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