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:
@@ -1,72 +0,0 @@
|
||||
// Code generated by relspecgo. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
resolvespec_common "github.com/bitechdev/ResolveSpec/pkg/spectypes"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
type ModelPublicUsers struct {
|
||||
bun.BaseModel `bun:"table:public.users,alias:users"`
|
||||
ID resolvespec_common.SqlString `bun:"id,type:varchar(36),pk," json:"id"` // UUID
|
||||
Active bool `bun:"active,type:boolean,default:true,notnull," json:"active"`
|
||||
CreatedAt resolvespec_common.SqlTimeStamp `bun:"created_at,type:timestamp,default:now(),notnull," json:"created_at"`
|
||||
DeletedAt resolvespec_common.SqlTimeStamp `bun:"deleted_at,type:timestamp,nullzero," json:"deleted_at"` // Soft delete
|
||||
Email resolvespec_common.SqlString `bun:"email,type:varchar(255),notnull," json:"email"`
|
||||
FullName resolvespec_common.SqlString `bun:"full_name,type:varchar(255),nullzero," json:"full_name"`
|
||||
Password resolvespec_common.SqlString `bun:"password,type:varchar(255),notnull," json:"password"` // Bcrypt hashed password
|
||||
Role resolvespec_common.SqlString `bun:"role,type:varchar(50),default:'user',notnull," json:"role"` // admin
|
||||
UpdatedAt resolvespec_common.SqlTimeStamp `bun:"updated_at,type:timestamp,default:now(),notnull," json:"updated_at"`
|
||||
Username resolvespec_common.SqlString `bun:"username,type:varchar(255),notnull," json:"username"`
|
||||
RelUserIDPublicAPIKeys []*ModelPublicAPIKeys `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicapikeys,omitempty"` // Has many ModelPublicAPIKeys
|
||||
RelUserIDPublicHooks []*ModelPublicHooks `bun:"rel:has-many,join:id=user_id" json:"reluseridpublichooks,omitempty"` // Has many ModelPublicHooks
|
||||
RelUserIDPublicWhatsappAccounts []*ModelPublicWhatsappAccounts `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicwhatsappaccounts,omitempty"` // Has many ModelPublicWhatsappAccounts
|
||||
RelUserIDPublicEventLogs []*ModelPublicEventLogs `bun:"rel:has-many,join:id=user_id" json:"reluseridpubliceventlogs,omitempty"` // Has many ModelPublicEventLogs
|
||||
RelUserIDPublicSessions []*ModelPublicSessions `bun:"rel:has-many,join:id=user_id" json:"reluseridpublicsessions,omitempty"` // Has many ModelPublicSessions
|
||||
}
|
||||
|
||||
// TableName returns the table name for ModelPublicUsers
|
||||
func (m ModelPublicUsers) TableName() string {
|
||||
return "public.users"
|
||||
}
|
||||
|
||||
// TableNameOnly returns the table name without schema for ModelPublicUsers
|
||||
func (m ModelPublicUsers) TableNameOnly() string {
|
||||
return "users"
|
||||
}
|
||||
|
||||
// SchemaName returns the schema name for ModelPublicUsers
|
||||
func (m ModelPublicUsers) SchemaName() string {
|
||||
return "public"
|
||||
}
|
||||
|
||||
// GetID returns the primary key value
|
||||
func (m ModelPublicUsers) GetID() int64 {
|
||||
return m.ID.Int64()
|
||||
}
|
||||
|
||||
// GetIDStr returns the primary key as a string
|
||||
func (m ModelPublicUsers) GetIDStr() string {
|
||||
return fmt.Sprintf("%d", m.ID)
|
||||
}
|
||||
|
||||
// SetID sets the primary key value
|
||||
func (m ModelPublicUsers) SetID(newid int64) {
|
||||
m.UpdateID(newid)
|
||||
}
|
||||
|
||||
// UpdateID updates the primary key value
|
||||
func (m *ModelPublicUsers) UpdateID(newid int64) {
|
||||
m.ID.FromString(fmt.Sprintf("%d", newid))
|
||||
}
|
||||
|
||||
// GetIDName returns the name of the primary key column
|
||||
func (m ModelPublicUsers) GetIDName() string {
|
||||
return "id"
|
||||
}
|
||||
|
||||
// GetPrefix returns the table prefix
|
||||
func (m ModelPublicUsers) GetPrefix() string {
|
||||
return "USE"
|
||||
}
|
||||
Reference in New Issue
Block a user