Skip to content
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

Fix: change default value for WalletTransaction metadata #2609

Merged
merged 4 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
6 changes: 3 additions & 3 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand Down Expand Up @@ -80,7 +80,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand Down Expand Up @@ -111,7 +111,7 @@
granted_credits: "0.0",
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand All @@ -136,7 +136,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand Down Expand Up @@ -165,7 +165,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand Down Expand Up @@ -199,7 +199,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand All @@ -224,7 +224,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand Down Expand Up @@ -253,7 +253,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand All @@ -277,7 +277,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand All @@ -302,7 +302,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand Down Expand Up @@ -331,7 +331,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand Down Expand Up @@ -426,7 +426,7 @@
granted_credits: recurring_transaction_rule.granted_credits.to_s,
source: :interval,
invoice_requires_successful_payment: true,
metadata: {}
metadata: []
}
)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/services/wallets/threshold_top_up_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
granted_credits: "3.0",
source: :threshold,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand Down Expand Up @@ -132,7 +132,7 @@
granted_credits: "0.0",
source: :threshold,
invoice_requires_successful_payment: false,
metadata: {}
metadata: []
}
)
end
Expand Down