package schema

import (
	"time"

	"gorm.io/gorm"
)

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

	RegionId uint64 `gorm:"not null;uniqueIndex:region_identity_unique_idx"`

	Identity string `gorm:"not null;type:VARCHAR(255);uniqueIndex:region_identity_unique_idx"`
}

// DefaultProviderIdentity defines the default identity for a provider in a specific region and tenant.
// If RegionId is 0, it means the default identity for all regions under the tenant.
// If TenantId is 0, it means the default identity for all tenants in the region.
type DefaultProviderIdentity struct {
	gorm.Model

	// not null provider id
	ProviderId  uint64 `gorm:"not null;uniqueIndex:idx_provider_serviceplan_region_tenant"`
	ServicePlan string `gorm:"not null;type:VARCHAR(64);uniqueIndex:idx_provider_serviceplan_region_tenant"`
	// if the region id is 0, it means the default identity for all regions under the tenant
	RegionId uint64 `gorm:"not null;uniqueIndex:idx_provider_serviceplan_region_tenant"`
	// if the tenant id is 0, it means the default identity for all tenants in the region
	TenantId uint64 `gorm:"not null;uniqueIndex:idx_provider_serviceplan_region_tenant"`
	Identity string `gorm:"not null;type:VARCHAR(255)"`
}
