package entities

import (
	"time"

	"gorm.io/gorm"
)

type Phases struct {
	Id            uint           `gorm:"primaryKey"`
	Name          string         `gorm:"not null"`
	IsActive      bool           `gorm:"not null;default:true"`
	Category      string         `gorm:"type:category_code;not null"`
	CreatedAt     time.Time      `gorm:"autoCreateTime"`
	DeletedAt     gorm.DeletedAt `gorm:"index" json:"-"`
	ActivityCount int            `gorm:"-" json:"-"`

	Activities []PhaseActivity `gorm:"foreignKey:PhaseId;references:Id"`
}

type PhaseActivity struct {
	Id          uint           `gorm:"primaryKey"`
	PhaseId     uint           `gorm:"not null"`
	Name        string         `gorm:"not null"`
	Description *string        `gorm:"type:text"`
	TimeType    *string        `gorm:"type:text"`
	CreatedAt   time.Time      `gorm:"autoCreateTime"`
	UpdatedAt   time.Time      `gorm:"autoUpdateTime"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`

	Phase Phases `gorm:"foreignKey:PhaseId;references:Id"`
}

type Checklist struct {
	Id          uint    `gorm:"primaryKey"`
	Name        string  `gorm:"not null"`
	Description *string `gorm:"type:text"`
	PhaseId     *uint
	CreatedAt   time.Time      `gorm:"autoCreateTime"`
	UpdatedAt   time.Time      `gorm:"autoUpdateTime"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`

	Phase *Phases `gorm:"foreignKey:PhaseId;references:Id"`
}
