feat(models): add new models for public API, event log, hook, session, user, and whatsapp account
* Introduced ModelPublicAPIKey, ModelPublicEventLog, ModelPublicHook, ModelPublicSession, ModelPublicUser, and ModelPublicWhatsappAccount * Removed deprecated ModelPublicUsers * Updated database schema definitions to reflect new model structure * Adjusted seed data to use correct types for timestamps
This commit is contained in:
69
pkg/models/sql_public_event_log.go
Normal file
69
pkg/models/sql_public_event_log.go
Normal file
@@ -0,0 +1,69 @@
|
||||
// Code generated by relspecgo. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type ModelPublicEventLog struct {
|
||||
bun.BaseModel `bun:"table:public.event_log,alias:event_log"`
|
||||
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
||||
Action resolvespec_common.SqlString `bun:"action,type:varchar(50),nullzero," json:"action"` // create
|
||||
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
||||
Data resolvespec_common.SqlString `bun:"data,type:text,nullzero," json:"data"` // JSON encoded event data
|
||||
EntityID resolvespec_common.SqlString `bun:"entity_id,type:varchar(36),nullzero," json:"entity_id"`
|
||||
EntityType resolvespec_common.SqlString `bun:"entity_type,type:varchar(100),nullzero," json:"entity_type"` // user
|
||||
Error resolvespec_common.SqlString `bun:"error,type:text,nullzero," json:"error"`
|
||||
EventType resolvespec_common.SqlString `bun:"event_type,type:varchar(100),notnull," json:"event_type"`
|
||||
IpAddress resolvespec_common.SqlString `bun:"ip_address,type:varchar(50),nullzero," json:"ip_address"`
|
||||
Success bool `bun:"success,type:boolean,default:true,notnull," json:"success"`
|
||||
UserAgent resolvespec_common.SqlString `bun:"user_agent,type:text,nullzero," json:"user_agent"`
|
||||
UserID resolvespec_common.SqlString `bun:"user_id,type:varchar(36),nullzero," json:"user_id"` // Optional user reference
|
||||
}
|
||||
|
||||
// TableName returns the table name for ModelPublicEventLog
|
||||
func (m ModelPublicEventLog) TableName() string {
|
||||
return "public.event_log"
|
||||
}
|
||||
|
||||
// TableNameOnly returns the table name without schema for ModelPublicEventLog
|
||||
func (m ModelPublicEventLog) TableNameOnly() string {
|
||||
return "event_log"
|
||||
}
|
||||
|
||||
// SchemaName returns the schema name for ModelPublicEventLog
|
||||
func (m ModelPublicEventLog) SchemaName() string {
|
||||
return "public"
|
||||
}
|
||||
|
||||
// GetID returns the primary key value
|
||||
func (m ModelPublicEventLog) GetID() int64 {
|
||||
return m.ID.Int64()
|
||||
}
|
||||
|
||||
// GetIDStr returns the primary key as a string
|
||||
func (m ModelPublicEventLog) GetIDStr() string {
|
||||
return fmt.Sprintf("%d", m.ID)
|
||||
}
|
||||
|
||||
// SetID sets the primary key value
|
||||
func (m ModelPublicEventLog) SetID(newid int64) {
|
||||
m.UpdateID(newid)
|
||||
}
|
||||
|
||||
// UpdateID updates the primary key value
|
||||
func (m *ModelPublicEventLog) UpdateID(newid int64) {
|
||||
m.ID.FromString(fmt.Sprintf("%d", newid))
|
||||
}
|
||||
|
||||
// GetIDName returns the name of the primary key column
|
||||
func (m ModelPublicEventLog) GetIDName() string {
|
||||
return "id"
|
||||
}
|
||||
|
||||
// GetPrefix returns the table prefix
|
||||
func (m ModelPublicEventLog) GetPrefix() string {
|
||||
return "ELV"
|
||||
}
|
||||
Reference in New Issue
Block a user