Skip to content

Commit

Permalink
feat: let database generate dates when updating transactions metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Oct 16, 2024
1 parent 1d0e9bc commit 18b92e9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,4 @@ begin

return new;
end
$$;
--
-- --todo: add test for changing logs format of created transaction and reverted transaction
$$;
4 changes: 2 additions & 2 deletions internal/storage/ledger/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func (s *Store) UpdateTransactionMetadata(ctx context.Context, id int, m metadat
Where("id = ?", id).
Where("ledger = ?", s.ledger.Name).
Set("metadata = metadata || ?", m).
Set("updated_at = ?", time.Now()).
Set("updated_at = (now() at time zone 'utc')").
Where("not (metadata @> ?)", m).
Returning("*"),
)
Expand All @@ -474,7 +474,7 @@ func (s *Store) DeleteTransactionMetadata(ctx context.Context, id int, key strin
Model(&ledger.Transaction{}).
ModelTableExpr(s.GetPrefixedRelationName("transactions")).
Set("metadata = metadata - ?", key).
Set("updated_at = ?", time.Now()).
Set("updated_at = (now() at time zone 'utc')").
Where("id = ?", id).
Where("ledger = ?", s.ledger.Name).
Where("metadata -> ? is not null", key).
Expand Down

0 comments on commit 18b92e9

Please sign in to comment.