AI SDK
Currently, the conversations and messages tables use a direct user_id column:
$table->foreignId('user_id')->nullable();
This assumes that every conversation belongs to a User model. However, there are cases where conversation context may need to be associated with other model types instead of only authenticated users.
For example:
Guest sessions
Custom customer models
Organizations/workspaces
AI agents or bots
External identities
Multi-tenant applications
Would it make sense to support a polymorphic relationship for conversation ownership instead of coupling it directly to user_id?
Something similar to:
$table->nullableMorphs('conversable');
This could make the conversation system more flexible for applications where the owner of the conversation is not always a User model.
AI SDK
Currently, the conversations and messages tables use a direct user_id column:
$table->foreignId('user_id')->nullable();
This assumes that every conversation belongs to a User model. However, there are cases where conversation context may need to be associated with other model types instead of only authenticated users.
For example:
Guest sessions
Custom customer models
Organizations/workspaces
AI agents or bots
External identities
Multi-tenant applications
Would it make sense to support a polymorphic relationship for conversation ownership instead of coupling it directly to user_id?
Something similar to:
$table->nullableMorphs('conversable');
This could make the conversation system more flexible for applications where the owner of the conversation is not always a User model.