Consolidate backend: drop vendored APwhy, converge on goose + sqlc

Phase 0 cleanup verified end-to-end:

- Delete vendored APwhy runtime (cmd/apwhy, internal/apwhy) and the
  unwired copy (internal/api/server.go + static bundle + cloned
  internal/{storage,analytics,auth,rbac}) — ~7.5k lines of dead code.
- Keep Containr's native internal/gateway; move APwhy management
  routes under /api/v1/gateway/* so they stop colliding with the
  native /services paths. Fix handlers against the real schema:
  UUID ids via RETURNING, integer enabled flags, plan validation,
  service validate endpoint, unique-violation mapping.
- Port agents.go off GORM onto sqlc (sqlc/queries/agents.sql);
  drop gorm dependencies; fix sqlc schema drift (services.environment_id).
- Replace the SELECT 1 goose baseline with the real consolidated
  schema (52 tables) minus APwhy's parallel auth/RBAC objects;
  idempotent via IF NOT EXISTS / OR REPLACE / guarded DO blocks so it
  replays cleanly over legacy installs. Add a drop migration for the
  dead objects and delete the legacy filename-tracked migrations/
  loader, directory, and Dockerfile copy. Verified via cmd/migrate:
  fresh install 53 tables, legacy upgrade clean to 20260917000000.
- Canvas: add invisible React Flow handles to ServiceNode so inferred
  auto-connections stop emitting warning #008.
- Remove reactflow dep (superseded by @xyflow/react), test harness
  cmds, and legacy 0001_init.sql backups.

Authored By: TDvorak <[email protected]>
This commit is contained in:
Tomas Dvorak committed 2026-09-17 09:40:08 +02:00
1 parent 37a56dc6b6
commit 9e3aa3aa17
153 files changed
+6996 -11135

No files matched your search

-29
View File
@@ -1,29 +0,0 @@
package main
import (
"fmt"
"log"
"net/http"
"containr/internal/apwhy/api"
"containr/internal/apwhy/config"
"containr/internal/apwhy/storage"
)
func main() {
cfg := config.Load()
store, err := storage.Open(cfg)
if err != nil {
log.Fatalf("failed to initialize storage: %v", err)
}
defer store.Close()
server := api.NewServer(store, cfg)
addr := fmt.Sprintf(":%d", cfg.Port)
log.Printf("APwhy server listening on http://localhost%s", addr)
if err := http.ListenAndServe(addr, server.Handler()); err != nil {
log.Fatalf("server exited: %v", err)
}
}
+4 -19
View File
@@ -25,11 +25,6 @@ func main() {
}
defer db.Close()
legacyDir := os.Getenv("LEGACY_MIGRATIONS_DIR")
if legacyDir == "" {
legacyDir = "migrations"
}
gooseDir := os.Getenv("GOOSE_MIGRATIONS_DIR")
if gooseDir == "" {
gooseDir = "migrations_goose"
@@ -41,24 +36,14 @@ func main() {
}
switch command {
case "up":
case "up", "goose-up":
migrationCtx, migrationCancel := context.WithTimeout(context.Background(), cfg.MigrationLockTimeout)
if err := db.MigrateAllWithLock(migrationCtx, legacyDir, gooseDir); err != nil {
if err := db.MigrateAllWithLock(migrationCtx, gooseDir); err != nil {
migrationCancel()
log.Fatalf("Migration failed: %v", err)
}
migrationCancel()
log.Println("Legacy + goose migrations completed successfully")
case "legacy-up":
if err := db.Migrate(legacyDir); err != nil {
log.Fatalf("Legacy migration failed: %v", err)
}
log.Println("Legacy migrations completed successfully")
case "goose-up":
if err := db.MigrateGoose(gooseDir); err != nil {
log.Fatalf("Goose migration failed: %v", err)
}
log.Println("Goose migrations completed successfully")
log.Println("Migrations completed successfully")
case "goose-status":
if err := db.GooseStatus(gooseDir); err != nil {
log.Fatalf("Goose status failed: %v", err)
@@ -73,6 +58,6 @@ func main() {
}
log.Printf("Created goose migration %q in %q", name, gooseDir)
default:
log.Fatalf("Unknown command %q. Supported commands: up | legacy-up | goose-up | goose-status | goose-create", command)
log.Fatalf("Unknown command %q. Supported commands: up | goose-status | goose-create", command)
}
}
+1 -1
View File
@@ -39,7 +39,7 @@ func main() {
// Run startup migrations unless explicitly disabled.
if cfg.AutoMigrate {
migrationCtx, migrationCancel := context.WithTimeout(context.Background(), cfg.MigrationLockTimeout)
if err := db.MigrateAllWithLock(migrationCtx, "migrations", "migrations_goose"); err != nil {
if err := db.MigrateAllWithLock(migrationCtx, "migrations_goose"); err != nil {
migrationCancel()
log.Fatalf("Failed to run database migrations: %v", err)
}
@@ -1,54 +0,0 @@
package main
import (
"context"
"fmt"
"containr/internal/build"
)
func main() {
fmt.Println("🧪 Testing Build Manager Detection...")
// Test build type detection on the current project
fmt.Println("\n📁 Testing on current project (has package.json)...")
// Note: We can't fully test BuildManager without a docker client,
// but we can test the detection logic
// Create mock scenarios
testCases := []struct {
name string
expected string
}{
{"Node.js project (package.json)", "railpack"},
{"Python project (requirements.txt)", "railpack"},
{"Go project (go.mod)", "railpack"},
{"Dockerfile project", "dockerfile"},
{"Unknown project", "nixpacks"},
}
fmt.Println("\n🎯 Expected detection priorities:")
for _, tc := range testCases {
fmt.Printf(" • %s → %s\n", tc.name, tc.expected)
}
// Test Railpack builder directly
builder := build.NewRailpackBuilder("/tmp/test", nil)
fmt.Println("\n🔍 Testing Railpack detection on current project:")
err := builder.DetectRailpack(context.Background(), "/home/tdvorak/Desktop/PROG+HTML/Containr")
if err != nil {
fmt.Printf("❌ Detection failed: %v\n", err)
} else {
fmt.Println("✅ Railpack can build this project!")
}
fmt.Println("\n📋 Build Priority Order:")
fmt.Println(" 1. Dockerfile (if present)")
fmt.Println(" 2. Railpack (primary choice)")
fmt.Println(" 3. Nixpacks (fallback)")
fmt.Println(" 4. Prebuilt (manual)")
fmt.Println("\n🚀 Build Manager Integration Test Complete!")
}
-32
View File
@@ -1,32 +0,0 @@
package main
import (
"context"
"fmt"
"containr/internal/build"
)
func main() {
// Create a RailpackBuilder
builder := build.NewRailpackBuilder("/tmp/containr-build-test", nil)
// Test detection on the current project (has package.json)
fmt.Println("Testing Railpack detection on current project...")
err := builder.DetectRailpack(context.Background(), "/home/tdvorak/Desktop/PROG+HTML/Containr")
if err != nil {
fmt.Printf("❌ Railpack detection failed: %v\n", err)
} else {
fmt.Println("✅ Railpack can build this project!")
}
// Show supported frameworks
fmt.Println("\nSupported frameworks:")
frameworks := builder.GetSupportedFrameworks()
for _, fw := range frameworks {
fmt.Printf(" - %s\n", fw)
}
fmt.Println("\n✅ Railpack integration test completed successfully!")
}