package bootstrap

import (
	"log"
	"strings"

	"github.com/nexuscrm/backend/internal/domain/schema"
)

// GetManagedTableDefinitions returns substrate table definitions only.
// Standard business objects (Account, Contact, Lead, etc.) are now owned
// by the PlatformCore pack and are not included here.
func GetManagedTableDefinitions() []schema.TableDefinition {
	defs := GetSystemTableDefinitions()

	seen := make(map[string]string, len(defs))
	for _, def := range defs {
		key := strings.ToLower(def.TableName)
		if prev, exists := seen[key]; exists {
			log.Fatalf("duplicate managed table definition for %s (%s vs %s)", def.TableName, prev, def.TableType)
		}
		seen[key] = def.TableType
	}

	return defs
}
