package k8scalendar

import (
	"time"

	"github.com/tidbcloud/devops/models/base"
)

type VersionLifecycle struct {
	base.Updatable

	Cloud                         string     `gorm:"column:cloud;type:varchar(16);not null;uniqueIndex:uk_cloud_version"`
	Version                       string     `gorm:"column:version;type:varchar(32);not null;uniqueIndex:uk_cloud_version"`
	CloudProvider                 string     `gorm:"column:cloud_provider;type:varchar(16);not null"`
	LifecycleStart                time.Time  `gorm:"column:lifecycle_start;type:timestamp;not null"`
	EndOfStandardSupport          time.Time  `gorm:"column:end_of_standard_support;type:timestamp;not null"`
	EndOfExtendedSupport          *time.Time `gorm:"column:end_of_extended_support;type:timestamp"`
	ReleasePrecision              string     `gorm:"column:release_precision;type:varchar(16);not null"`
	SourceURL                     string     `gorm:"column:source_url;type:varchar(512)"`
	Fingerprint                   string     `gorm:"column:fingerprint;type:varchar(128);not null"`
	ScrapedAt                     time.Time  `gorm:"column:scraped_at;type:timestamp;not null"`
	NotifiedVersionAddedAt        *time.Time `gorm:"column:notified_version_added_at;type:timestamp"`
	NotifiedEOSChangedFingerprint string     `gorm:"column:notified_eos_changed_fingerprint;type:varchar(128)"`
	EOSApproachingNotifiedFor     *time.Time `gorm:"column:eos_approaching_notified_for;type:timestamp"`
}

func (VersionLifecycle) TableName() string {
	return "k8s_version_lifecycles"
}

type VersionLifecycleSnapshot struct {
	base.Base

	Cloud                string     `gorm:"column:cloud;type:varchar(16);not null"`
	Version              string     `gorm:"column:version;type:varchar(32);not null"`
	CloudProvider        string     `gorm:"column:cloud_provider;type:varchar(16);not null"`
	LifecycleStart       time.Time  `gorm:"column:lifecycle_start;type:timestamp;not null"`
	EndOfStandardSupport time.Time  `gorm:"column:end_of_standard_support;type:timestamp;not null"`
	EndOfExtendedSupport *time.Time `gorm:"column:end_of_extended_support;type:timestamp"`
	ReleasePrecision     string     `gorm:"column:release_precision;type:varchar(16);not null"`
	Fingerprint          string     `gorm:"column:fingerprint;type:varchar(128);not null"`
	ScrapedAt            time.Time  `gorm:"column:scraped_at;type:timestamp;not null;index:idx_scraped_at"`
}

func (VersionLifecycleSnapshot) TableName() string {
	return "k8s_version_lifecycle_snapshots"
}
