Skip to content

Commit 85a62db

Browse files
committed
add transform for StripeCustomer
1 parent cae3734 commit 85a62db

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

scripts/database_migration.exs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ defmodule DatabaseMigration do
4040
"BountyCharge" => "transactions",
4141
"BountyTransfer" => "transactions",
4242
"GithubInstallation" => "installations",
43-
"StripeAccount" => "accounts"
43+
"StripeAccount" => "accounts",
44+
"StripeCustomer" => "customers"
4445
}
4546

4647
@schema_mappings %{
@@ -56,11 +57,13 @@ defmodule DatabaseMigration do
5657
"BountyCharge" => Transaction,
5758
"BountyTransfer" => Transaction,
5859
"GithubInstallation" => Installation,
59-
"StripeAccount" => Account
60+
"StripeAccount" => Account,
61+
"StripeCustomer" => Customer
6062
}
6163

6264
@backfilled_tables [
6365
"accounts",
66+
"customers",
6467
"installations",
6568
"repositories",
6669
"transactions",
@@ -473,6 +476,19 @@ defmodule DatabaseMigration do
473476
}
474477
end
475478

479+
defp transform("StripeCustomer", row, _db) do
480+
%{
481+
"id" => row["id"],
482+
"provider" => "stripe",
483+
"provider_id" => row["stripe_id"],
484+
"provider_meta" => nil,
485+
"name" => row["name"],
486+
"user_id" => row["org_id"],
487+
"inserted_at" => row["created_at"],
488+
"updated_at" => row["updated_at"]
489+
}
490+
end
491+
476492
defp transform(_, _row, _db), do: nil
477493

478494
def process_dump(input_file, output_file) do

scripts/v1-progress.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,13 @@
463463
- period: -1
464464
- source: -1
465465
- "StripeCustomer":
466-
- id: 0
467-
- created_at: 0
468-
- updated_at: 0
469-
- stripe_id: 0
470-
- org_id: 0
471-
- name: 0
472-
- region: 0
466+
- id: 1
467+
- created_at: 1
468+
- updated_at: 1
469+
- stripe_id: 1
470+
- org_id: 1
471+
- name: 1
472+
- region: -1
473473
- "StripePaymentMethod":
474474
- id: 0
475475
- created_at: 0

scripts/v2-progress.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@
9090
- inserted_at: 0
9191
- updated_at: 0
9292
- customers:
93-
- id: 0
94-
- provider: 0
95-
- provider_id: 0
96-
- provider_meta: 0
97-
- name: 0
98-
- user_id: 0
99-
- inserted_at: 0
100-
- updated_at: 0
93+
- id: 1
94+
- provider: 1
95+
- provider_id: 1
96+
- provider_meta: -1
97+
- name: 1
98+
- user_id: 1
99+
- inserted_at: 1
100+
- updated_at: 1
101101
- event_cursors:
102102
- id: 0
103103
- provider: 0

0 commit comments

Comments
 (0)