Add uuid to ApplicationSetting

parent 159e9e6c
class AddUuidToApplicationSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column :application_settings, :uuid, :string
add_concurrent_index :application_settings, :uuid
execute("UPDATE application_settings SET uuid = #{quote(generate_random_string(40))}")
end
def down
remove_index :application_settings, :uuid if index_exists?(:application_settings, :uuid)
remove_column :application_settings, :uuid
end
private
def generate_random_string(size)
# urlsafe_base64 may return a string of size * 4/3
SecureRandom.urlsafe_base64(size)[0, size]
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170317203554) do
ActiveRecord::Schema.define(version: 20170328010804) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -129,8 +129,11 @@ ActiveRecord::Schema.define(version: 20170317203554) do
t.string "elasticsearch_aws_access_key"
t.string "elasticsearch_aws_secret_access_key"
t.integer "geo_status_timeout", default: 10
t.string "uuid"
end
add_index "application_settings", ["uuid"], name: "index_application_settings_on_uuid", using: :btree
create_table "approvals", force: :cascade do |t|
t.integer "merge_request_id", null: false
t.integer "user_id", null: false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment