package schema

import (
	"time"

	"gorm.io/gorm"
)

type ClusterConfigBackupPolicy struct {
	gorm.Model

	ClusterID           uint64     `gorm:"index:,unique"`
	Enabled             bool       `gorm:"index;default:false"`
	IntervalSec         int32      `gorm:"not null;default:3600"`
	NextRunAt           *time.Time `gorm:"index"`
	LastBackupAt        *time.Time `gorm:"index"`
	LastSuccessAt       *time.Time `gorm:"index"`
	LastError           string     `gorm:"type:TEXT"`
	DeleteBackupPending bool       `gorm:"index;default:false"`
	DeletePolicyPending bool       `gorm:"index;default:false"`

	Cluster *Cluster `gorm:"foreignkey:ClusterID"`
}

type ClusterConfigBackup struct {
	gorm.Model

	ClusterID           uint64 `gorm:"index:,unique"`
	SystemVariables     string `gorm:"type:JSON"`
	PdConfig            string `gorm:"type:JSON"`
	PdServerConfig      string `gorm:"type:JSON"`
	PlacementRules      string `gorm:"type:JSON"`
	StoreLimits         string `gorm:"type:JSON"`
	NewCollationEnabled *bool
	CapturedAt          time.Time `gorm:"index"`

	Cluster *Cluster `gorm:"foreignkey:ClusterID"`
}
