package schema

import (
	"time"

	"gorm.io/gorm"
)

type EncryptionKey struct {
	ID        uint64 `gorm:"primaryKey;not null"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`

	TenantId uint64 `gorm:"index:name_tenant;not null"`

	ProviderId uint64 `gorm:"not null"`
	// Provider   *Provider `gorm:"foreignkey:ProviderId"`
	RegionId uint64 `gorm:"not null"`
	// Region   *Region `gorm:"foreignkey:RegionId"`

	ProviderIdentityId uint64 `gorm:"not null"`
	CustomerManaged    bool   `gorm:"not null"`
	ServicePlan        string `gorm:"type:VARCHAR(255);default:''"`
	MasterKey          string `gorm:"index"` // for aws, it's the KMS key ARN;

	State string `gorm:"not null;default:''"`
	// InitialDataplaneId only for DefaultEncryptionKey,
	// it means the first dataplane, which we used to route to dataplane manager.
	InitialDataplaneId   string `gorm:"not null;default:''"`
	AuthorizedDataplanes string `gorm:"not null"`

	Provider *Provider `gorm:"foreignkey:ProviderId"`
	Region   *Region   `gorm:"foreignkey:RegionId"`
}
