Skip to content

Commit b9cfba8

Browse files
committed
Verify Team#account and Team#account.plans migration
1 parent 5b92f5b commit b9cfba8

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

Rakefile

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ namespace :team do
2121
right = mongo.send(attr)
2222

2323
if left != right
24-
puts "#{attr} | #{left} != #{right} | pg:#{pg.id} | mongo:#{mongo.id}"
24+
puts "#{attr} | pg:#{pg.id} | mongo:#{mongo.id}| #{left} != #{right}"
25+
true
26+
else
27+
false
2528
end
2629
rescue => ex
2730
puts '*'*80
@@ -42,8 +45,11 @@ namespace :team do
4245
mongo_id = pg_team.mongo_id
4346
mongo_team = Team.find(mongo_id)
4447

48+
# Ignoring:
49+
# - updated_at
50+
4551
# Team
46-
%i(updated_at median score total slug mean pending_join_requests).each do |attr|
52+
%i(median score total slug mean pending_join_requests).each do |attr|
4753
neq(attr, pg_team, mongo_team, false)
4854
end
4955

@@ -52,14 +58,26 @@ namespace :team do
5258
end
5359

5460
# TODO: Account
55-
unless mongo_team.account.nil? || pg_team.account.nil?
56-
%i(stripe_card_token stripe_customer_token admin_id).each do |attr|
61+
if mongo_team.account.present? && pg_team.account.blank?
62+
puts "account | pg:#{pg_team.id} | mongo:#{mongo_team.id}| The account was not migrated."
63+
end
64+
65+
if mongo_team.account.present? && pg_team.account.present?
66+
check_plans = %i(stripe_card_token stripe_customer_token admin_id).map do |attr|
5767
neq(attr, pg_team.account, mongo_team.account)
68+
end.any? { |x| !x }
69+
70+
# TODO: Plans
71+
if check_plans
72+
left = pg_team.account.plans.pluck(:id).sort
73+
right = mongo_team.account.plan_ids.sort
74+
75+
if left != right
76+
puts "account.plans | pg:#{pg_team.id} | mongo:#{mongo_team.id}| #{left} != #{right}"
77+
end
5878
end
5979
end
6080

61-
# TODO: Plans
62-
6381
# TODO: Locations
6482

6583
# TODO: Links

0 commit comments

Comments
 (0)