diff options
Diffstat (limited to 'db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb')
-rw-r--r-- | db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb b/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb deleted file mode 100644 index 16053408fe0..00000000000 --- a/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb +++ /dev/null @@ -1,32 +0,0 @@ -# rubocop:disable all -# Create visibility level field on DB -# Sets default_visibility_level to value on settings if not restricted -# If value is restricted takes higher visibility level allowed - -class AddDefaultGroupVisibilityToApplicationSettings < ActiveRecord::Migration[4.2] - def up - add_column :application_settings, :default_group_visibility, :integer - # Unfortunately, this can't be a `default`, since we don't want the configuration specific - # `allowed_visibility_level` to end up in schema.rb - - visibility_level = allowed_visibility_level || Gitlab::VisibilityLevel::PRIVATE - execute("UPDATE application_settings SET default_group_visibility = #{visibility_level}") - end - - def down - remove_column :application_settings, :default_group_visibility - end - - private - - def allowed_visibility_level - application_settings = select_one("SELECT restricted_visibility_levels FROM application_settings ORDER BY id DESC LIMIT 1") - if application_settings - restricted_visibility_levels = YAML.safe_load(application_settings["restricted_visibility_levels"]) rescue nil - end - restricted_visibility_levels ||= [] - - allowed_levels = Gitlab::VisibilityLevel.values - restricted_visibility_levels - allowed_levels.max - end -end |