Skip to content

Commit cae3734

Browse files
committed
add transform for StripeAccount
1 parent a672b9f commit cae3734

File tree

3 files changed

+66
-32
lines changed

3 files changed

+66
-32
lines changed

scripts/database_migration.exs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ defmodule DatabaseMigration do
3939
"Claim" => "claims",
4040
"BountyCharge" => "transactions",
4141
"BountyTransfer" => "transactions",
42-
"GithubInstallation" => "installations"
42+
"GithubInstallation" => "installations",
43+
"StripeAccount" => "accounts"
4344
}
4445

4546
@schema_mappings %{
@@ -54,10 +55,20 @@ defmodule DatabaseMigration do
5455
"Claim" => Claim,
5556
"BountyCharge" => Transaction,
5657
"BountyTransfer" => Transaction,
57-
"GithubInstallation" => Installation
58+
"GithubInstallation" => Installation,
59+
"StripeAccount" => Account
5860
}
5961

60-
@backfilled_tables ["installations", "repositories", "transactions", "claims", "bounties", "tickets", "users"]
62+
@backfilled_tables [
63+
"accounts",
64+
"installations",
65+
"repositories",
66+
"transactions",
67+
"claims",
68+
"bounties",
69+
"tickets",
70+
"users"
71+
]
6172

6273
@relevant_tables Map.keys(@table_mappings)
6374

@@ -439,6 +450,29 @@ defmodule DatabaseMigration do
439450
}
440451
end
441452

453+
defp transform("StripeAccount", row, _db) do
454+
%{
455+
"id" => row["id"],
456+
"provider" => "stripe",
457+
"provider_id" => row["stripe_id"],
458+
"provider_meta" => nil,
459+
"name" => nil,
460+
"details_submitted" => row["details_submitted"],
461+
"charges_enabled" => row["charges_enabled"],
462+
"service_agreement" => row["service_agreement"],
463+
"country" => row["country"],
464+
"type" => row["type"],
465+
"stale" => row["needs_refresh"],
466+
"user_id" => row["user_id"],
467+
"inserted_at" => row["created_at"],
468+
"updated_at" => row["updated_at"],
469+
"payouts_enabled" => nil,
470+
"payout_interval" => nil,
471+
"payout_speed" => nil,
472+
"default_currency" => nil
473+
}
474+
end
475+
442476
defp transform(_, _row, _db), do: nil
443477

444478
def process_dump(input_file, output_file) do

scripts/v1-progress.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -439,17 +439,17 @@
439439
- amount: -1
440440
- currency: -1
441441
- "StripeAccount":
442-
- id: 0
443-
- created_at: 0
444-
- updated_at: 0
445-
- user_id: 0
446-
- details_submitted: 0
447-
- charges_enabled: 0
448-
- service_agreement: 0
449-
- country: 0
450-
- type: 0
451-
- region: 0
452-
- needs_refresh: 0
442+
- id: 1
443+
- created_at: 1
444+
- updated_at: 1
445+
- user_id: 1
446+
- details_submitted: 1
447+
- charges_enabled: 1
448+
- service_agreement: 1
449+
- country: 1
450+
- type: 1
451+
- region: -1
452+
- needs_refresh: 1
453453
- "StripeBalanceTransaction":
454454
- stripe_id: -1
455455
- created: -1

scripts/v2-progress.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
- accounts:
2-
- id: 0
3-
- provider: 0
4-
- provider_id: 0
5-
- provider_meta: 0
6-
- name: 0
7-
- details_submitted: 0
8-
- charges_enabled: 0
9-
- service_agreement: 0
10-
- country: 0
11-
- type: 0
12-
- stale: 0
13-
- user_id: 0
14-
- inserted_at: 0
15-
- updated_at: 0
16-
- payouts_enabled: 0
17-
- payout_interval: 0
18-
- payout_speed: 0
19-
- default_currency: 0
2+
- id: 1
3+
- provider: 1
4+
- provider_id: 1
5+
- provider_meta: -1
6+
- name: -1
7+
- details_submitted: 1
8+
- charges_enabled: 1
9+
- service_agreement: 1
10+
- country: 1
11+
- type: 1
12+
- stale: 1
13+
- user_id: 1
14+
- inserted_at: 1
15+
- updated_at: 1
16+
- payouts_enabled: -1
17+
- payout_interval: -1
18+
- payout_speed: -1
19+
- default_currency: -1
2020
- attempts:
2121
- id: 0
2222
- status: 0

0 commit comments

Comments
 (0)