prosgarz35 opened a new pull request, #3204:
URL: https://github.com/apache/james-project/pull/3204
### Rationale & Context
In the PostgreSQL backend schema:
- The `message_mailbox` table had a foreign key constraint referencing
`message(message_id)`, but lacked a foreign key referencing
`mailbox(mailbox_id)`.
- The `mailbox_member` table also lacked a foreign key constraint
referencing `mailbox(mailbox_id)`.
While `mailbox_annotations` correctly specified:
```java
DSL.constraint().foreignKey(MAILBOX_ID)
.references(PostgresMailboxTable.TABLE_NAME,
PostgresMailboxTable.MAILBOX_ID)
.onDeleteCascade()
The absence of cascading foreign keys in message_mailbox and
mailbox_member meant that if a mailbox was deleted (via
PostgresMailboxDAO.delete) and subsequent event bus processing or listener
execution failed/crashed, orphaned
"zombie" message references and member associations would permanently
remain in the database.
### Changes
1. Add ON DELETE CASCADE foreign key in PostgresMessageDataDefinition:
• Added foreign key constraint on message_mailbox.mailbox_id
referencing mailbox.mailbox_id with onDeleteCascade().
2. Add ON DELETE CASCADE foreign key in
PostgresMailboxMemberDataDefinition:
• Added foreign key constraint on mailbox_member.mailbox_id
referencing mailbox.mailbox_id with onDeleteCascade().
This ensures referential integrity at the database layer consistent with
mailbox_annotations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]