saveinmed/backend/cmd/fix_db/main.go
Gabbriiel 90467db1ec refactor: substitui backend Medusa por backend Go e corrige testes do marketplace
- 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>
2026-02-17 04:56:37 -06:00

41 lines
1 KiB
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)
}
log.Printf("Connecting to DB: %s", cfg.DatabaseURL)
db, err := sqlx.Connect("pgx", cfg.DatabaseURL)
if err != nil {
log.Fatalf("Connection failed: %v", err)
}
defer db.Close()
query := `
ALTER TABLE cart_items ADD COLUMN IF NOT EXISTS batch TEXT;
ALTER TABLE cart_items ADD COLUMN IF NOT EXISTS expires_at DATE;
ALTER TABLE products ADD COLUMN IF NOT EXISTS batch TEXT DEFAULT '';
ALTER TABLE products ADD COLUMN IF NOT EXISTS stock BIGINT DEFAULT 0;
ALTER TABLE products ADD COLUMN IF NOT EXISTS expires_at DATE DEFAULT CURRENT_DATE;
`
log.Println("Executing Schema Fix (Adding batch/expires_at to cart_items)...")
_, err = db.Exec(query)
if err != nil {
log.Fatalf("Migration failed: %v", err)
}
log.Println("SUCCESS: Schema updated.")
}