package main

import (
	"context"
	"fmt"
	"os"

	"github.com/jackc/pgx/v5"
)

func main() {
	ctx := context.Background()
	connStr := os.Getenv("MIP_DB")
	if connStr == "" {
		connStr = "postgres://user:password@localhost:5432/mydatabase?sslmode=disable"
	}

	conn, err := pgx.Connect(ctx, connStr)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Unable to connect: %v\n", err)
		os.Exit(1)
	}
	defer conn.Close(ctx)

	_, err = conn.Exec(ctx, "TRUNCATE TABLE shock_brand_specs RESTART IDENTITY CASCADE")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Truncate failed: %v\n", err)
		os.Exit(1)
	}
	fmt.Println("Cleared shock_brand_specs table")
}