mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 23:45:21 +02:00
Replace existing entryable type references in DB
This commit is contained in:
parent
5ce6011137
commit
f70765c897
3 changed files with 40 additions and 6 deletions
|
@ -105,10 +105,6 @@ class TransactionsController < ApplicationController
|
|||
entry_params
|
||||
end
|
||||
|
||||
def bulk_update_params
|
||||
params.require(:bulk_update).permit(:date, :notes, :category_id, :merchant_id, entry_ids: [], tag_ids: [])
|
||||
end
|
||||
|
||||
def search_params
|
||||
cleaned_params = params.fetch(:q, {})
|
||||
.permit(
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
disabled: true
|
||||
) %>
|
||||
<% else %>
|
||||
<%= render "account/transfer_matches/matching_fields",
|
||||
<%= render "transfer_matches/matching_fields",
|
||||
form: f, entry: @entry, candidates: @transfer_match_candidates.map { |pm| pm.outflow_transaction.entry }, accounts: @accounts %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -49,7 +49,7 @@
|
|||
disabled: true
|
||||
) %>
|
||||
<% else %>
|
||||
<%= render "account/transfer_matches/matching_fields",
|
||||
<%= render "transfer_matches/matching_fields",
|
||||
form: f, entry: @entry, candidates: @transfer_match_candidates.map { |pm| pm.inflow_transaction.entry }, accounts: @accounts %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -8,5 +8,43 @@ class TableRenames < ActiveRecord::Migration[7.2]
|
|||
|
||||
rename_table :account_balances, :balances
|
||||
rename_table :account_holdings, :holdings
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
execute <<~SQL
|
||||
UPDATE entries
|
||||
SET entryable_type = CASE
|
||||
WHEN entryable_type = 'Account::Transaction' THEN 'Transaction'
|
||||
WHEN entryable_type = 'Account::Trade' THEN 'Trade'
|
||||
WHEN entryable_type = 'Account::Valuation' THEN 'Valuation'
|
||||
END
|
||||
SQL
|
||||
|
||||
execute <<~SQL
|
||||
UPDATE taggings
|
||||
SET taggable_type = CASE
|
||||
WHEN taggable_type = 'Account::Transaction' THEN 'Transaction'
|
||||
END
|
||||
SQL
|
||||
end
|
||||
|
||||
dir.down do
|
||||
execute <<~SQL
|
||||
UPDATE entries
|
||||
SET entryable_type = CASE
|
||||
WHEN entryable_type = 'Transaction' THEN 'Account::Transaction'
|
||||
WHEN entryable_type = 'Trade' THEN 'Account::Trade'
|
||||
WHEN entryable_type = 'Valuation' THEN 'Account::Valuation'
|
||||
END
|
||||
SQL
|
||||
|
||||
execute <<~SQL
|
||||
UPDATE taggings
|
||||
SET taggable_type = CASE
|
||||
WHEN taggable_type = 'Transaction' THEN 'Account::Transaction'
|
||||
END
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue