-
Notifications
You must be signed in to change notification settings - Fork 19
fix(schema): add network field to ProviderOrderToken unique constraint and implement two-phase provider profile updates #516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
a2f5b5d
7d5c3ee
3ef2e32
39fadcd
9e5a909
e4f0c0a
a9573d7
c424639
111c388
bcb9f37
5bf8cb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -714,7 +714,9 @@ func TestProvider(t *testing.T) { | |
"status": "success", | ||
"message": "Node is live", | ||
"data": map[string]interface{}{ | ||
"currencies": []string{"NGN"}, | ||
"serviceInfo": map[string]interface{}{ | ||
"currencies": []string{"NGN"}, | ||
}, | ||
}, | ||
}) | ||
}, | ||
|
@@ -1509,14 +1511,29 @@ func TestProvider(t *testing.T) { | |
}) | ||
assert.NoError(t, err) | ||
|
||
// Create a provision bucket for the order | ||
provisionBucket, err := db.Client.ProvisionBucket. | ||
Create(). | ||
SetMinAmount(decimal.NewFromFloat(100.0)). | ||
SetMaxAmount(decimal.NewFromFloat(1000.0)). | ||
SetCurrency(testCtx.currency). | ||
Save(context.Background()) | ||
assert.NoError(t, err) | ||
|
||
// Add provision bucket to the order | ||
order, err = order.Update(). | ||
SetProvisionBucket(provisionBucket). | ||
Save(context.Background()) | ||
assert.NoError(t, err) | ||
|
||
orderKey := fmt.Sprintf("order_request_%s", order.ID) | ||
|
||
user, err := test.CreateTestUser(map[string]interface{}{ | ||
"email": "[email protected]", | ||
}) | ||
assert.NoError(t, err) | ||
|
||
providerProfile, err := test.CreateTestProviderProfile(map[string]interface{}{ | ||
_, err = test.CreateTestProviderProfile(map[string]interface{}{ | ||
"user_id": user.ID, | ||
"currency_id": testCtx.currency.ID, | ||
}) | ||
|
@@ -1525,7 +1542,7 @@ func TestProvider(t *testing.T) { | |
orderRequestData := map[string]interface{}{ | ||
"amount": order.Amount.Mul(order.Rate).RoundBank(0).String(), | ||
"institution": order.Institution, | ||
"providerId": providerProfile.ID, | ||
"providerId": testCtx.provider.ID, // Use the same provider as the order | ||
} | ||
|
||
err = db.RedisClient.HSet(context.Background(), orderKey, orderRequestData).Err() | ||
|
@@ -1563,6 +1580,21 @@ func TestProvider(t *testing.T) { | |
}) | ||
assert.NoError(t, err) | ||
|
||
// Create a provision bucket for the order | ||
provisionBucket, err := db.Client.ProvisionBucket. | ||
Create(). | ||
SetMinAmount(decimal.NewFromFloat(100.0)). | ||
SetMaxAmount(decimal.NewFromFloat(1000.0)). | ||
SetCurrency(testCtx.currency). | ||
Save(context.Background()) | ||
assert.NoError(t, err) | ||
|
||
// Add provision bucket to the order | ||
order, err = order.Update(). | ||
SetProvisionBucket(provisionBucket). | ||
Save(context.Background()) | ||
assert.NoError(t, err) | ||
|
||
orderKey := fmt.Sprintf("order_request_%s", order.ID) | ||
|
||
orderRequestData := map[string]interface{}{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- Drop index "providerordertoken_provider_pr_6a0d0c64fd46fb967691502cb58fa192" from table: "provider_order_tokens" | ||
DROP INDEX "providerordertoken_provider_pr_6a0d0c64fd46fb967691502cb58fa192"; | ||
|
||
-- Backfill NULL networks from tokens.network -> networks.identifier | ||
UPDATE provider_order_tokens pot | ||
SET network = n.identifier | ||
FROM tokens t | ||
JOIN networks n ON n.id = t.network_tokens | ||
WHERE pot.network IS NULL | ||
AND pot.token_provider_order_tokens = t.id; | ||
|
||
-- Modify "provider_order_tokens" table | ||
ALTER TABLE "provider_order_tokens" ALTER COLUMN "network" SET NOT NULL; | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
-- Create index "providerordertoken_network_pro_78d86f7d16ed79216b911727a796323a" to table: "provider_order_tokens" | ||
CREATE UNIQUE INDEX "providerordertoken_network_pro_78d86f7d16ed79216b911727a796323a" ON "provider_order_tokens" ("network", "provider_profile_order_tokens", "token_provider_order_tokens", "fiat_currency_provider_order_tokens"); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.