package model

import (
	"encoding/json"
	"time"

	"gorm.io/gorm"
)

// InstallationConfig represents a platform-level configuration key-value.
// Reference: Chatwoot InstallationConfig model + P2B M12 spec
type InstallationConfig struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	Name      string         `gorm:"size:255;not null;uniqueIndex" json:"name"`
	Value     json.RawMessage `gorm:"type:jsonb" json:"value"`
	CreatedAt time.Time      `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt time.Time      `gorm:"autoUpdateTime" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
}

func (InstallationConfig) TableName() string { return "installation_configs" }