feat(db): migrate transactions table to composite primary key

- Change primary key from internalTransactionId to (accountId, transactionId)
- Add transactionId as stable bank-provided identifier
- Update INSERT to INSERT OR REPLACE for upsert behavior
- Update migration detection logic for composite key structure
- Update tests to include transactionId in sample data
This commit is contained in:
Elisiário Couto
2025-09-10 23:36:09 +01:00
parent f47644e8c6
commit a00d6ce2ce
4 changed files with 45 additions and 36 deletions

View File

@@ -176,6 +176,7 @@ class TestAccountsAPI:
"""Test successful retrieval of account transactions from database."""
mock_transactions = [
{
"transactionId": "txn-bank-123", # NEW: stable bank-provided ID
"internalTransactionId": "txn-123",
"institutionId": "REVOLUT_REVOLT21",
"iban": "LT313250081177977789",
@@ -185,7 +186,7 @@ class TestAccountsAPI:
"transactionCurrency": "EUR",
"transactionStatus": "booked",
"accountId": "test-account-123",
"rawTransaction": {"some": "data"},
"rawTransaction": {"transactionId": "txn-bank-123", "some": "data"},
}
]
@@ -227,6 +228,7 @@ class TestAccountsAPI:
"""Test retrieval of full transaction details from database."""
mock_transactions = [
{
"transactionId": "txn-bank-123", # NEW: stable bank-provided ID
"internalTransactionId": "txn-123",
"institutionId": "REVOLUT_REVOLT21",
"iban": "LT313250081177977789",
@@ -236,7 +238,7 @@ class TestAccountsAPI:
"transactionCurrency": "EUR",
"transactionStatus": "booked",
"accountId": "test-account-123",
"rawTransaction": {"some": "raw_data"},
"rawTransaction": {"transactionId": "txn-bank-123", "some": "raw_data"},
}
]