fix(models): update models to use public schema and correct types
Some checks failed
CI / Test (1.22) (push) Failing after -23m2s
CI / Test (1.23) (push) Failing after -22m58s
CI / Lint (push) Has been cancelled
CI / Build (push) Has been cancelled

* Rename models to plural form for consistency
* Change table names to include 'public' schema
* Update timestamp types to SqlTimeStamp for consistency
* Adjust relationships to use pluralized user models
This commit is contained in:
Hein
2026-02-20 16:11:23 +02:00
parent 3fb65e0285
commit 524bc4179b
9 changed files with 233 additions and 199 deletions

View File

@@ -8,21 +8,21 @@ import (
)
type ModelPublicMessageCache struct {
bun.BaseModel `bun:"table:message_cache,alias:message_cache"`
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
AccountID resolvespec_common.SqlString `bun:"account_id,type:varchar(36),notnull," json:"account_id"`
ChatID resolvespec_common.SqlString `bun:"chat_id,type:varchar(255),notnull," json:"chat_id"`
Content resolvespec_common.SqlString `bun:"content,type:text,notnull," json:"content"` // JSON encoded message content
CreatedAt resolvespec_common.SqlTime `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
FromMe bool `bun:"from_me,type:boolean,notnull," json:"from_me"`
MessageID resolvespec_common.SqlString `bun:"message_id,type:varchar(255),notnull," json:"message_id"`
MessageType resolvespec_common.SqlString `bun:"message_type,type:varchar(50),notnull," json:"message_type"` // text
Timestamp resolvespec_common.SqlTime `bun:"timestamp,type:timestamp,notnull," json:"timestamp"`
bun.BaseModel `bun:"table:public.message_cache,alias:message_cache"`
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
AccountID resolvespec_common.SqlString `bun:"account_id,type:varchar(36),notnull," json:"account_id"`
ChatID resolvespec_common.SqlString `bun:"chat_id,type:varchar(255),notnull," json:"chat_id"`
Content resolvespec_common.SqlString `bun:"content,type:text,notnull," json:"content"` // JSON encoded message content
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
FromMe bool `bun:"from_me,type:boolean,notnull," json:"from_me"`
MessageID resolvespec_common.SqlString `bun:"message_id,type:varchar(255),notnull," json:"message_id"`
MessageType resolvespec_common.SqlString `bun:"message_type,type:varchar(50),notnull," json:"message_type"` // text
Timestamp resolvespec_common.SqlTimeStamp `bun:"timestamp,type:timestamp,notnull," json:"timestamp"`
}
// TableName returns the table name for ModelPublicMessageCache
func (m ModelPublicMessageCache) TableName() string {
return "message_cache"
return "public.message_cache"
}
// TableNameOnly returns the table name without schema for ModelPublicMessageCache