fix(models): correct inverted belongsTo keys on ChatMessage.session (#921)
foreignKey/localKey were swapped on the ChatMessage → ChatSession
relation. Per Lucid's belongsTo contract, foreignKey is the column
on the child model and localKey is on the parent — so this must be
{ foreignKey: 'session_id', localKey: 'id' }, mirroring the inverse
hasMany on ChatSession.
The relation is not currently preloaded anywhere in the codebase, so
no runtime behavior changes today; this closes a latent bug that
would have broken any future preload('session') call.
This commit is contained in:
parent
a5fe52f66f
commit
82f67debc1
|
|
@ -18,7 +18,7 @@ export default class ChatMessage extends BaseModel {
|
|||
@column()
|
||||
declare content: string
|
||||
|
||||
@belongsTo(() => ChatSession, { foreignKey: 'id', localKey: 'session_id' })
|
||||
@belongsTo(() => ChatSession, { foreignKey: 'session_id', localKey: 'id' })
|
||||
declare session: BelongsTo<typeof ChatSession>
|
||||
|
||||
@column.dateTime({ autoCreate: true })
|
||||
|
|
|
|||
Loading…
Reference in New Issue