Skip to content
Snippets Groups Projects
Commit 07b4c1b2 authored by Sean McGivern's avatar Sean McGivern Committed by Lin Jen-Shin
Browse files

Merge branch '2246-uuid-is-nil-for-new-installation' into 'master'

Lazily set UUID in ApplicationSetting for new installations

Closes gitlab-ee#2246

See merge request !10893
parent d3123f67
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -28,6 +28,8 @@ class ApplicationSetting < ActiveRecord::Base
 
attr_accessor :domain_whitelist_raw, :domain_blacklist_raw
 
validates :uuid, presence: true
validates :session_expire_delay,
presence: true,
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
Loading
Loading
@@ -159,6 +161,7 @@ class ApplicationSetting < ActiveRecord::Base
end
end
 
before_validation :ensure_uuid!
before_save :ensure_runners_registration_token
before_save :ensure_health_check_access_token
 
Loading
Loading
@@ -344,6 +347,12 @@ class ApplicationSetting < ActiveRecord::Base
 
private
 
def ensure_uuid!
return if uuid?
self.uuid = SecureRandom.uuid
end
def check_repository_storages
invalid = repository_storages - Gitlab.config.repositories.storages.keys
errors.add(:repository_storages, "can't include: #{invalid.join(", ")}") unless
Loading
Loading
---
title: Lazily sets UUID in ApplicationSetting for new installations
merge_request:
author:
class FillMissingUuidOnApplicationSettings < ActiveRecord::Migration
DOWNTIME = false
def up
execute("UPDATE application_settings SET uuid = #{quote(SecureRandom.uuid)} WHERE uuid is NULL")
end
def down
end
end
Loading
Loading
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
 
ActiveRecord::Schema.define(version: 20170423064036) do
ActiveRecord::Schema.define(version: 20170426175636) do
 
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Loading
Loading
Loading
Loading
@@ -4,6 +4,7 @@ describe ApplicationSetting, models: true do
let(:setting) { ApplicationSetting.create_from_defaults }
 
it { expect(setting).to be_valid }
it { expect(setting.uuid).to be_present }
 
describe 'validations' do
let(:http) { 'http://example.com' }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment