Skip to content

Commit

Permalink
update staging.rb in seeds to have same seeding process as production.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
pengyin-shan committed Feb 1, 2023
1 parent 52a09c2 commit 39aa9b6
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions db/seeds/staging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@
# frozen_string_literal: true
# warn_indent: true

########## This file serves for the sandbox testing after 3.0 release
########## For sandbox only
# Steps:
# 1) change default database to production database, then run `rails export:build_sandbox_data` to generate production-related data
# 2) switch database to the sandbox database
# 3) run rake db:seed or created alongside the db with db:setup to seed data
##########

# Forcing load seed file in sequence by last number
# seeds_1 to seeds_3 are rake-generated. Other seeds file are manually edited
puts 'run seeds.rb file now...'
Dir[File.join(Rails.root, 'db', 'seeds', 'sandbox', '*.rb')].sort.each_with_index do |seed, index|
if seed.include? index.to_s
load seed
end
end
########## Uncomment following if we need to redo sandbox data injection
# puts 'run seeds.rb file now...'
# Dir[File.join(Rails.root, 'db', 'seeds', 'sandbox', '*.rb')].sort.each_with_index do |seed, index|
# if seed.include? index.to_s
# load seed
# end
# end


######## For 3.1.0 Migration only
Rake::Task['before_seeds:copy_data'].invoke
Dir[File.join(Rails.root, 'db', 'seeds', 'staging', '*.rb')].sort.each_with_index do |seed, index|
puts 'run staging/seeds_' + index.to_s + '.rb now..'
load seed
end
Rake::Task['rewrite_postgres:retrieve_data'].invoke

0 comments on commit 39aa9b6

Please sign in to comment.