Merge pull request #4299 from tchak/fix-flipper-initialize
Correctly create new flipper flags
This commit is contained in:
commit
8758caf7f4
1 changed files with 11 additions and 6 deletions
|
@ -16,12 +16,10 @@ end
|
||||||
# this will immediately migrate the default features to be controlled.
|
# this will immediately migrate the default features to be controlled.
|
||||||
def setup_features(features)
|
def setup_features(features)
|
||||||
features.each do |feature|
|
features.each do |feature|
|
||||||
if Flipper.exist?(feature)
|
if !Flipper.exist?(feature)
|
||||||
return
|
# Disable feature by default
|
||||||
|
Flipper.disable(feature)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Disable feature by default
|
|
||||||
Flipper.disable(feature)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,8 +37,15 @@ features = [
|
||||||
:xray
|
:xray
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def database_exists?
|
||||||
|
ActiveRecord::Base.connection
|
||||||
|
true
|
||||||
|
rescue ActiveRecord::NoDatabaseError
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
ActiveSupport.on_load(:active_record) do
|
ActiveSupport.on_load(:active_record) do
|
||||||
if ActiveRecord::Base.connection.data_source_exists? 'flipper_features'
|
if database_exists? && ActiveRecord::Base.connection.data_source_exists?('flipper_features')
|
||||||
setup_features(features)
|
setup_features(features)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue