// Code generated by relspecgo. DO NOT EDIT.
package models

import (
	"fmt"
	resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes"
	"github.com/uptrace/bun"
)

type ModelPublicMessageCache struct {
	bun.BaseModel `bun:"table:public.message_cache,alias:message_cache"`
	ID            resolvespec_common.SqlString    `bun:"id,type:varchar(128),pk," json:"id"`
	AccountID     resolvespec_common.SqlString    `bun:"account_id,type:varchar(64),notnull," json:"account_id"`
	EventType     resolvespec_common.SqlString    `bun:"event_type,type:varchar(100),notnull," json:"event_type"`
	EventData     resolvespec_common.SqlString    `bun:"event_data,type:jsonb,notnull," json:"event_data"`
	MessageID     resolvespec_common.SqlString    `bun:"message_id,type:varchar(255),notnull," json:"message_id"`
	FromNumber    resolvespec_common.SqlString    `bun:"from_number,type:varchar(64),notnull," json:"from_number"`
	ToNumber      resolvespec_common.SqlString    `bun:"to_number,type:varchar(64),notnull," json:"to_number"`
	Reason        resolvespec_common.SqlString    `bun:"reason,type:text,notnull," json:"reason"`
	Attempts      int                             `bun:"attempts,type:integer,default:0,notnull," json:"attempts"`
	Timestamp     resolvespec_common.SqlTimeStamp `bun:"timestamp,type:timestamp,default:now(),notnull," json:"timestamp"`
	LastAttempt   resolvespec_common.SqlTimeStamp `bun:"last_attempt,type:timestamp,nullzero," json:"last_attempt"`
	CreatedAt     resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
}

// TableName returns the table name for ModelPublicMessageCache
func (m ModelPublicMessageCache) TableName() string {
	return "public.message_cache"
}

// TableNameOnly returns the table name without schema for ModelPublicMessageCache
func (m ModelPublicMessageCache) TableNameOnly() string {
	return "message_cache"
}

// SchemaName returns the schema name for ModelPublicMessageCache
func (m ModelPublicMessageCache) SchemaName() string {
	return "public"
}

// GetID returns the primary key value
func (m ModelPublicMessageCache) GetID() int64 {
	return m.ID.Int64()
}

// GetIDStr returns the primary key as a string
func (m ModelPublicMessageCache) GetIDStr() string {
	return fmt.Sprintf("%d", m.ID)
}

// SetID sets the primary key value
func (m ModelPublicMessageCache) SetID(newid int64) {
	m.UpdateID(newid)
}

// UpdateID updates the primary key value
func (m *ModelPublicMessageCache) UpdateID(newid int64) {
	m.ID.FromString(fmt.Sprintf("%d", newid))
}

// GetIDName returns the name of the primary key column
func (m ModelPublicMessageCache) GetIDName() string {
	return "id"
}

// GetPrefix returns the table prefix
func (m ModelPublicMessageCache) GetPrefix() string {
	return "MCE"
}
