package models

import "time"

type AstrologerExperience struct {
	ID uint `gorm:"primaryKey" json:"id"`

	AstrologerID uint `gorm:"column:astrologer_id;not null;index" json:"astrologer_id"`

	Title string `gorm:"column:title;type:varchar(255);not null" json:"title"`

	Organization string `gorm:"column:organization;type:varchar(255);not null" json:"organization"`

	// Decimal years, so half a year survives the round trip. The column is a
	// DECIMAL(4,1) as of migrations/2026_09_07_astrologer_experience_decimal.sql;
	// it was an INT, which rounded 1.5 down to 1 on the way in.
	ExperienceYears float64 `gorm:"column:experience_years;type:decimal(4,1)" json:"experience_years"`

	StartDate *time.Time `gorm:"column:start_date" json:"start_date,omitempty"`

	EndDate *time.Time `gorm:"column:end_date" json:"end_date,omitempty"`

	// The years the API actually takes, added by
	// migrations/2026_09_09_astrologer_experience_years.sql. start_date and
	// end_date above are the older pair and no endpoint writes them.
	StartYear int `gorm:"column:start_year" json:"start_year"`

	EndYear int `gorm:"column:end_year" json:"end_year"`

	// currently_working in the request and the response; is_current is the
	// column that has always held it.
	IsCurrent bool `gorm:"column:is_current;default:false" json:"currently_working"`

	Description string `gorm:"column:description;type:text" json:"description"`

	Certificate string `gorm:"column:certificate;type:varchar(255)" json:"certificate"`

	Status string `gorm:"column:status;type:enum('PENDING','APPROVED','REJECTED');default:'PENDING'" json:"status"`

	CreatedAt *time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at,omitempty"`

	UpdatedAt *time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at,omitempty"`

	// Relationship
	Astrologer Astrologer `gorm:"foreignKey:AstrologerID;references:ID" json:"-"`
}

func (AstrologerExperience) TableName() string {

	return "astrologer_experiences"

}
