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

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

type ModelPublicPlans struct {
	bun.BaseModel                            `bun:"table:public.plans,alias:plans"`
	ID                                       resolvespec_common.SqlInt64       `bun:"id,type:bigserial,pk,autoincrement," json:"id"`
	CompletedAt                              resolvespec_common.SqlTimeStamp   `bun:"completed_at,type:timestamptz,nullzero," json:"completed_at"`
	CreatedAt                                resolvespec_common.SqlTimeStamp   `bun:"created_at,type:timestamptz,default:now(),notnull," json:"created_at"`
	Description                              resolvespec_common.SqlString      `bun:"description,type:text,default:'',notnull," json:"description"`
	DueDate                                  resolvespec_common.SqlTimeStamp   `bun:"due_date,type:timestamptz,nullzero," json:"due_date"`
	GUID                                     resolvespec_common.SqlUUID        `bun:"guid,type:uuid,default:gen_random_uuid(),notnull," json:"guid"`
	LastReviewedAt                           resolvespec_common.SqlTimeStamp   `bun:"last_reviewed_at,type:timestamptz,nullzero," json:"last_reviewed_at"`
	Owner                                    resolvespec_common.SqlString      `bun:"owner,type:text,nullzero," json:"owner"`
	Priority                                 resolvespec_common.SqlString      `bun:"priority,type:text,default:'medium',notnull," json:"priority"` // low, medium, high, critical
	ProjectID                                resolvespec_common.SqlInt64       `bun:"project_id,type:bigint,nullzero," json:"project_id"`
	ReviewedBy                               resolvespec_common.SqlString      `bun:"reviewed_by,type:text,nullzero," json:"reviewed_by"`
	Status                                   resolvespec_common.SqlString      `bun:"status,type:text,default:'draft',notnull," json:"status"` // draft, active, blocked, completed, cancelled, superseded
	SupersedesPlanID                         resolvespec_common.SqlInt64       `bun:"supersedes_plan_id,type:bigint,nullzero," json:"supersedes_plan_id"`
	Tags                                     resolvespec_common.SqlStringArray `bun:"tags,type:text[],default:'{}',notnull," json:"tags"`
	Title                                    resolvespec_common.SqlString      `bun:"title,type:text,notnull," json:"title"`
	UpdatedAt                                resolvespec_common.SqlTimeStamp   `bun:"updated_at,type:timestamptz,default:now(),notnull," json:"updated_at"`
	RelProjectID                             *ModelPublicProjects              `bun:"rel:has-one,join:project_id=id" json:"relprojectid,omitempty"`                                      // Has one ModelPublicProjects
	RelSupersedesPlanID                      *ModelPublicPlans                 `bun:"rel:has-one,join:supersedes_plan_id=id" json:"relsupersedesplanid,omitempty"`                       // Has one ModelPublicPlans
	RelDependsOnPlanIDPublicPlanDependencies []*ModelPublicPlanDependencies    `bun:"rel:has-many,join:id=depends_on_plan_id" json:"reldependsonplanidpublicplandependencies,omitempty"` // Has many ModelPublicPlanDependencies
	RelPlanIDPublicPlanDependencies          []*ModelPublicPlanDependencies    `bun:"rel:has-many,join:id=plan_id" json:"relplanidpublicplandependencies,omitempty"`                     // Has many ModelPublicPlanDependencies
	RelPlanAIDPublicPlanRelatedPlans         []*ModelPublicPlanRelatedPlans    `bun:"rel:has-many,join:id=plan_a_id" json:"relplanaidpublicplanrelatedplans,omitempty"`                  // Has many ModelPublicPlanRelatedPlans
	RelPlanBIDPublicPlanRelatedPlans         []*ModelPublicPlanRelatedPlans    `bun:"rel:has-many,join:id=plan_b_id" json:"relplanbidpublicplanrelatedplans,omitempty"`                  // Has many ModelPublicPlanRelatedPlans
	RelPlanIDPublicPlanSkills                []*ModelPublicPlanSkills          `bun:"rel:has-many,join:id=plan_id" json:"relplanidpublicplanskills,omitempty"`                           // Has many ModelPublicPlanSkills
	RelPlanIDPublicPlanGuardrails            []*ModelPublicPlanGuardrails      `bun:"rel:has-many,join:id=plan_id" json:"relplanidpublicplanguardrails,omitempty"`                       // Has many ModelPublicPlanGuardrails
}

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

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

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

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

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

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

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

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

// GetPrefix returns the table prefix
func (m ModelPublicPlans) GetPrefix() string {
	return "PLA"
}
