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

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

type ModelPublicLearnings struct {
	bun.BaseModel            `bun:"table:public.learnings,alias:learnings"`
	ID                       resolvespec_common.SqlInt64       `bun:"id,type:bigserial,pk,autoincrement," json:"id"`
	ActionRequired           bool                              `bun:"action_required,type:boolean,default:false,notnull," json:"action_required"`
	Area                     resolvespec_common.SqlString      `bun:"area,type:text,default:'other',notnull," json:"area"`
	Category                 resolvespec_common.SqlString      `bun:"category,type:text,default:'insight',notnull," json:"category"`
	Confidence               resolvespec_common.SqlString      `bun:"confidence,type:text,default:'hypothesis',notnull," json:"confidence"`
	CreatedAt                resolvespec_common.SqlTimeStamp   `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"`
	Details                  resolvespec_common.SqlString      `bun:"details,type:text,default:'',notnull," json:"details"`
	DuplicateOfLearningID    resolvespec_common.SqlInt64       `bun:"duplicate_of_learning_id,type:bigint,nullzero," json:"duplicate_of_learning_id"`
	GUID                     resolvespec_common.SqlUUID        `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"`
	Priority                 resolvespec_common.SqlString      `bun:"priority,type:text,default:'medium',notnull," json:"priority"`
	ProjectID                resolvespec_common.SqlInt64       `bun:"project_id,type:bigint,nullzero," json:"project_id"`
	RelatedSkillID           resolvespec_common.SqlInt64       `bun:"related_skill_id,type:bigint,nullzero," json:"related_skill_id"`
	RelatedThoughtID         resolvespec_common.SqlInt64       `bun:"related_thought_id,type:bigint,nullzero," json:"related_thought_id"`
	ReviewedAt               resolvespec_common.SqlTimeStamp   `bun:"reviewed_at,type:timestamptz,nullzero," json:"reviewed_at"`
	ReviewedBy               resolvespec_common.SqlString      `bun:"reviewed_by,type:text,nullzero," json:"reviewed_by"`
	SourceRef                resolvespec_common.SqlString      `bun:"source_ref,type:text,nullzero," json:"source_ref"`
	SourceType               resolvespec_common.SqlString      `bun:"source_type,type:text,nullzero," json:"source_type"`
	Status                   resolvespec_common.SqlString      `bun:"status,type:text,default:'pending',notnull," json:"status"`
	Summary                  resolvespec_common.SqlString      `bun:"summary,type:text,notnull," json:"summary"`
	SupersedesLearningID     resolvespec_common.SqlInt64       `bun:"supersedes_learning_id,type:bigint,nullzero," json:"supersedes_learning_id"`
	Tags                     resolvespec_common.SqlStringArray `bun:"tags,type:text[],default:'{}',notnull," json:"tags"`
	UpdatedAt                resolvespec_common.SqlTimeStamp   `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"`
	RelDuplicateOfLearningID *ModelPublicLearnings             `bun:"rel:has-one,join:duplicate_of_learning_id=id" json:"relduplicateoflearningid,omitempty"` // Has one ModelPublicLearnings
	RelProjectID             *ModelPublicProjects              `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"`                           // Has one ModelPublicProjects
	RelRelatedSkillID        *ModelPublicAgentSkills           `bun:"rel:has-one,join:related_skill_id=id" json:"relrelatedskillid,omitempty"`                // Has one ModelPublicAgentSkills
	RelRelatedThoughtID      *ModelPublicThoughts              `bun:"rel:has-one,join:related_thought_id=id" json:"relrelatedthoughtid,omitempty"`            // Has one ModelPublicThoughts
	RelSupersedesLearningID  *ModelPublicLearnings             `bun:"rel:has-one,join:supersedes_learning_id=id" json:"relsupersedeslearningid,omitempty"`    // Has one ModelPublicLearnings
}

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

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

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

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

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

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

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

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

// GetPrefix returns the table prefix
func (m ModelPublicLearnings) GetPrefix() string {
	return "LEA"
}
