Skip to content

refactor: rename SMS table log to a general messages table - #1804

Open
beesaferoot wants to merge 3 commits into
mainfrom
refactor/migrate-sms-to-generic-message
Open

beesaferoot wants to merge 3 commits into
mainfrom
refactor/migrate-sms-to-generic-message

Conversation

@beesaferoot

Copy link
Copy Markdown
Contributor

Closes #1793

This PR aims to be one of a sequence of efforts to achieve a generic messaging system on MPM as described in #1785

Major changes mage:

  • sms table becomes messages with a channel column; gateway tables reference it by message_id;
  • Sms model and send pipeline become Message* abstract.
  • Prepare codebase for generic messaging gateway and plugin abstraction.

Brief summary of the change made

Are there any other side effects of this change that we should be aware of?

Describe how you tested your changes?

Pull Request checklist

Please confirm you have completed any of the necessary steps below.

  • Meaningful Pull Request title and description
  • Changes tested as described above
  • Added appropriate documentation for the change.
  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

@dmohns dmohns left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking forward to this change 🙏 Added a tiny comment already

@beesaferoot
beesaferoot force-pushed the refactor/migrate-sms-to-generic-message branch from a34b42e to c1593d2 Compare December 2, 2026 20:00
@beesaferoot
beesaferoot marked this pull request as ready for review December 2, 2026 20:27
@beesaferoot
beesaferoot requested a review from dmohns December 2, 2026 21:03
@beesaferoot
beesaferoot force-pushed the refactor/migrate-sms-to-generic-message branch from 84d566f to 1592916 Compare December 3, 2026 10:39

@dmohns dmohns left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few more small comments, other than that LGTM

Comment thread src/backend/app/Models/Message.php Outdated
* @property string|null $trigger_type
* @property int|null $trigger_id
* @property string $body
* @property MessageChannel $channel

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required? Isn't MessageChannel essentially duplicating messaging_plugin_slug ?

* @property-read Sms|null $sms
* @property int $id
* @property int $message_id
* @property string $provider_message_id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call it external_message_id which signals "this is the id used in the third party system" ? Provider is a bit duplicated with AfricasTalkingMessage itself

public function trigger(): MorphTo {
return $this->morphTo();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the inverse ProviderMessage link here? For example providerTransaction similar to how it's done with Transactions.

- `sms` table becomes `messages` with a `channel` column; gateway tables reference it by `message_id`;
- `Sms` model and send pipeline become `Message*` abstract.
- Prepare codebase for generic messaging gateway and plugin abstraction.
- `airtel_sms_messages` references `messages` by `message_id`; the SMSC id moves to `provider_message_id`.
- Gateway resolver passes the `Message` record to the Airtel gateway.
- Remove the `channel` column and `MessageChannel` enum; the plugin slug already identifies the gateway.
- Rename `provider_message_id` to `external_message_id` in gateway tables.
- `messages` links to the gateway record through a `providerMessage` morph; gateway tables drop `sms_id`.
@beesaferoot
beesaferoot force-pushed the refactor/migrate-sms-to-generic-message branch from 1592916 to bf4b86a Compare December 4, 2026 17:08
@beesaferoot

Copy link
Copy Markdown
Contributor Author

I have addressed your comments. Kindly review @dmohns Thanks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Migrate Sms tables and Abstraction to Generic Messages

2 participants