package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"strings"
	"time"

	"github.com/tidbcloud/AgentTeam/internal/coredb/testkit"
)

func main() {
	rootDSN := strings.TrimSpace(os.Getenv("AGENTTEAM_TIDB_TEST_DSN"))
	if rootDSN == "" {
		log.Fatal("AGENTTEAM_TIDB_TEST_DSN is required")
	}

	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
	defer cancel()

	databaseName, err := testkit.PrepareMigratedTiDBTemplate(ctx, rootDSN)
	if err != nil {
		log.Fatalf("prepare tidb template database: %v", err)
	}

	fmt.Println(databaseName)
}
