fix: drop broken loan_events FK from loan_disputes migration#1289
Conversation
|
this is conflicting with main so it can't merge yet, please rebase: if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0 |
d544700 to
783b467
Compare
783b467 to
b2f9f9f
Compare
ogazboiz
left a comment
There was a problem hiding this comment.
merging this schema test, it inserts a loan_dispute and validates it against the schema, with a describeIf guard that skips cleanly when no db is available. one note: the title mentions dropping the loan_events FK but the diff is just the test now, looks like the fk-drop landed on main separately and the rebase left only the test here, which is fine. green.
if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0
Closes #1191
What does this PR do?
This PR resolves a database migration failure where
loan_disputesattempted to create a foreign key referencingloan_events(loan_id). Becauseloan_events.loan_idlacks a total unique constraint and acts as an append-only event log (and is later renamed to a view viacontract_events), PostgreSQL rejects the foreign key.Description
REFERENCES loan_events(loan_id)constraint from theloan_disputesschema migration. The schema now relies on application-level validation forloan_idassociations, which is already handled seamlessly by the existing robust controllers and indexed events flow.loan_disputesmigration will apply cleanly, unaffected by theloan_events->contract_eventsrename or the view creation that happens in subsequent migrations.loanDisputesSchema.test.ts) that asserts an actual dispute record can be cleanly inserted against the real database schema.