-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARCO-149: change callback column to allow saving multiple parameters (#…
…539) * ARCO-149: refactor callback column to allow saving multiple parameters * ARCO-149: fix unkeyed fields * ARCO-149: remove unnecessary comments * ARCO-149: refactor migrations and postgres methods * ARCO-149: remove goroutine from callback * ARCO-149: change direct comparisions to sql not null * ARCO-149: check callback url and token length instead of comparing to null * ARCO-149: revert defer func changes
1 parent
ae67cee
commit 03db169
Showing
11 changed files
with
172 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
internal/metamorph/store/postgresql/migrations/000016_multiple_callbacks.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- Step 1: Add the old 'callback_url' and 'callback_token' columns back | ||
ALTER TABLE metamorph.transactions | ||
ADD COLUMN callback_url TEXT, | ||
ADD COLUMN callback_token TEXT; | ||
|
||
-- Step 2: Populate 'callback_url' and 'callback_token' with the first object in the 'callbacks' JSON array | ||
UPDATE metamorph.transactions | ||
SET callback_url = (callbacks->0->>'callback_url'), | ||
callback_token = (callbacks->0->>'callback_token') | ||
WHERE jsonb_array_length(callbacks) > 0; | ||
|
||
-- Step 3: Drop the new 'callbacks' column | ||
ALTER TABLE metamorph.transactions | ||
DROP COLUMN callbacks; |
17 changes: 17 additions & 0 deletions
17
internal/metamorph/store/postgresql/migrations/000016_multiple_callbacks.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- Step 1: Add the new 'callback' column | ||
ALTER TABLE metamorph.transactions | ||
ADD COLUMN callbacks JSONB; | ||
|
||
-- Step 2: Populate the 'callback' column with data from 'callback_url' and 'callback_token' | ||
UPDATE metamorph.transactions | ||
SET callbacks = json_build_array( | ||
json_build_object( | ||
'callback_url', callback_url, | ||
'callback_token', callback_token | ||
) | ||
)WHERE LENGTH(callback_url) > 0 OR LENGTH(callback_token) > 0; | ||
|
||
-- Step 3: Drop the old 'callback_url' and 'callback_token' columns | ||
ALTER TABLE metamorph.transactions | ||
DROP COLUMN callback_url, | ||
DROP COLUMN callback_token; |
Oops, something went wrong.