- Remove backend Medusa.js (TypeScript) e substitui pelo backend Go (saveinmed-performance-core) - Corrige testes auth.test.ts: alinha paths de API (v1/ sem barra inicial) e campo access_token - Corrige GroupedProductCard.test.tsx: ajusta distância formatada (toFixed) e troca userEvent por fireEvent com fakeTimers - Corrige AuthContext.test.tsx: usa vi.hoisted() para mocks e corrige parênteses no waitFor Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
758 B
Go
33 lines
758 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
_ "github.com/jackc/pgx/v5/stdlib"
|
|
"github.com/jmoiron/sqlx"
|
|
"github.com/saveinmed/backend-go/internal/config"
|
|
)
|
|
|
|
func main() {
|
|
cfg, err := config.Load()
|
|
if err != nil {
|
|
log.Fatalf("failed to load config: %v", err)
|
|
}
|
|
db, err := sqlx.Open("pgx", cfg.DatabaseURL)
|
|
if err != nil {
|
|
log.Fatalf("Failed to open DB: %v", err)
|
|
}
|
|
defer db.Close()
|
|
|
|
if err := db.Ping(); err != nil {
|
|
log.Fatalf("Failed to ping DB: %v", err)
|
|
}
|
|
|
|
log.Println("Applying 0015_add_unique_cart_items.sql...")
|
|
query := `CREATE UNIQUE INDEX IF NOT EXISTS idx_cart_items_unique ON cart_items (buyer_id, product_id);`
|
|
_, err = db.Exec(query)
|
|
if err != nil {
|
|
log.Fatalf("Migration failed: %v", err)
|
|
}
|
|
log.Println("Migration successful!")
|
|
}
|