Skip to content

Commit 2b5c983

Browse files
committed
Add guard to prevent seeding non-sandbox overlays
This change results in an error being thrown when executing `bin/rails db:setup` without `ON_SANDBOX='true'` . This guard prevents db seeding of non-sandbox overlays.
1 parent f93bf7d commit 2b5c983

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

db/seeds/production.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
# Forcing load seed file in sequence by last number
1717
# seeds_1 to seeds_3 are rake-generated. Other seeds file are manually edited
1818
########## Uncomment following if we need to redo sandbox data injection
19+
20+
unless FeatureFlagHelper.enabled?(:on_sandbox)
21+
raise <<~ERROR
22+
ERROR: These seeds are for the sandbox overlay only!
23+
The ON_SANDBOX flag is not enabled.
24+
Please verify you are on the sandbox overlay and ON_SANDBOX='true' is set.
25+
Do NOT run db:setup against any non-sandbox overlays!
26+
ERROR
27+
end
28+
1929
puts 'run seeds.rb file now...'
2030
Dir[File.join(Rails.root, 'db', 'seeds', 'production', '*.rb')].sort.each_with_index do |seed, index|
2131
if seed.include? index.to_s

0 commit comments

Comments
 (0)