package models

import "time"

type AstrologerDocument struct {
	ID uint `gorm:"primaryKey" json:"id"`

	// UserID mirrors astrologers.userId. The column has always existed on
	// astrologer_documents but was missing from this struct, so every row was
	// inserted with a NULL user_id and a document could not be joined back to
	// its login without a second hop through astrologers.
	UserID uint `gorm:"column:user_id;index" json:"user_id"`

	AstrologerID uint `gorm:"column:astrologer_id;not null;index" json:"astrologer_id"`

	DocumentType string `gorm:"column:document_type;type:varchar(50);not null;index" json:"document_type"`

	DocumentNumber string `gorm:"column:document_number;type:varchar(100)" json:"document_number"`

	DocumentName string `gorm:"column:document_name;type:varchar(255)" json:"document_name"`

	FilePath string `gorm:"column:file_path;type:varchar(500);not null" json:"file_path"`

	FileSize int64 `gorm:"column:file_size" json:"file_size"`

	MimeType string `gorm:"column:mime_type;type:varchar(100)" json:"mime_type"`

	VerificationStatus string `gorm:"column:verification_status;type:enum('PENDING','APPROVED','REJECTED');default:'PENDING'" json:"verification_status"`

	VerifiedBy *uint `gorm:"column:verified_by" json:"verified_by"`

	VerifiedAt *time.Time `gorm:"column:verified_at" json:"verified_at"`

	Remarks string `gorm:"column:remarks;type:text" json:"remarks"`

	IsActive bool `gorm:"column:is_active;default:true" json:"is_active"`

	CreatedAt *time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`

	UpdatedAt *time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updated_at"`

	// Relationship
	Astrologer Astrologer `gorm:"foreignKey:AstrologerID;references:ID" json:"-"`
}

func (AstrologerDocument) TableName() string {

	return "astrologer_documents"

}
