package k8supgrade

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

// Notice stores the final rendered notice text for each task.
// It is only written when an admin explicitly modifies the notice.
type Notice struct {
	base.Updatable

	TaskID    uint64 `gorm:"column:task_id;type:bigint(20) unsigned;not null;uniqueIndex:uk_notice_task_id"`
	Title     string `gorm:"column:title;type:varchar(255)"`
	Content   string `gorm:"column:content;type:LONGTEXT"`
	UpdatedBy string `gorm:"column:updated_by;type:varchar(255)"`
}

func (Notice) TableName() string {
	return "k8s_upgrade_notice"
}

type NotifyLog struct {
	base.Base

	TaskID   uint64 `gorm:"column:task_id;type:bigint(20) unsigned;not null;index:idx_task_id"`
	Channel  string `gorm:"column:channel;type:varchar(32);not null"`
	Target   string `gorm:"column:target;type:varchar(512);not null"`
	PageURL  string `gorm:"column:page_url;type:varchar(1024)"`
	Status   string `gorm:"column:status;type:varchar(32);not null"`
	ErrorMsg string `gorm:"column:error_msg;type:varchar(1024)"`
	SentBy   string `gorm:"column:sent_by;type:varchar(255)"`
}

func (NotifyLog) TableName() string {
	return "k8s_upgrade_notify_logs"
}
