package schema

import "gorm.io/gorm"

type CustomerManagedEncryptionKey struct {
	gorm.Model

	TenantId   uint64 `gorm:"index"`
	ProjectId  uint64 `gorm:"index"`
	RegionId   uint64 `gorm:"index"`
	ProviderId uint64 `gorm:"index"`
	MasterKey  string `gorm:"index"` // for aws, it's the KMS key ARN; for azure, it's the Key Vault Key.

	AzureKeyVaultName        string `gorm:"type:VARCHAR(64)"`  // only used for azure
	AzureAppRegistrationId   string `gorm:"type:VARCHAR(64)"`  // only used for azure
	AzureAppRegistrationName string `gorm:"type:VARCHAR(64)"`  // only used for azure
	AzureAppRegistrationUmi  string `gorm:"type:VARCHAR(255)"` // only used for azure

	Region   Region   // A cmek belongs to a region.
	Provider Provider // A cmek belongs to a provider.
}

type ProjectCmekKeySuffix struct {
	gorm.Model

	ProjectId uint64 `gorm:"uniqueIndex"` // ProjectId is unique
	Salt      string `gorm:"type:VARCHAR(64);not null"`
	Suffix    string `gorm:"type:VARCHAR(16);not null"`
}
