-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: change default value for WalletTransaction metadata (#2609)
All api clients expect metadata to be returned as array (and when records are created, it's also an array), but if we create WalletTransaction without metadata, it takes default value of `{}` which then breaks api-clients
- Loading branch information
1 parent
fd78551
commit ef2dfc6
Showing
5 changed files
with
67 additions
and
17 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
db/migrate/20240920084727_change_wallet_transactions_metadata_default.rb
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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
class ChangeWalletTransactionsMetadataDefault < ActiveRecord::Migration[7.1] | ||
def up | ||
change_column_default :wallet_transactions, :metadata, [] | ||
safety_assured do | ||
execute <<-SQL | ||
UPDATE wallet_transactions | ||
SET metadata = '[]'::jsonb | ||
WHERE metadata = '{}'::jsonb; | ||
SQL | ||
end | ||
end | ||
|
||
def down | ||
change_column_default :wallet_transactions, :metadata, {} | ||
safety_assured do | ||
execute <<-SQL | ||
UPDATE wallet_transactions | ||
SET metadata = '{}'::jsonb | ||
WHERE metadata = '[]'::jsonb; | ||
SQL | ||
end | ||
end | ||
end |
25 changes: 25 additions & 0 deletions
25
db/migrate/20240920091133_change_recurring_transaction_rules_transaction_metadata_default.rb
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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
class ChangeRecurringTransactionRulesTransactionMetadataDefault < ActiveRecord::Migration[7.1] | ||
def up | ||
change_column_default :recurring_transaction_rules, :transaction_metadata, [] | ||
safety_assured do | ||
execute <<-SQL | ||
UPDATE recurring_transaction_rules | ||
SET transaction_metadata = '[]'::jsonb | ||
WHERE transaction_metadata = '{}'::jsonb; | ||
SQL | ||
end | ||
end | ||
|
||
def down | ||
change_column_default :recurring_transaction_rules, :transaction_metadata, {} | ||
safety_assured do | ||
execute <<-SQL | ||
UPDATE recurring_transaction_rules | ||
SET transaction_metadata = '{}'::jsonb | ||
WHERE transaction_metadata = '[]'::jsonb; | ||
SQL | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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