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

File diff suppressed because it is too large. Load diff
@@ -0,0 +1,28 @@
-- +goose Up
-- Removes APwhy's parallel auth/RBAC schema and leftover integration tables.
-- Better Auth owns identity; Containr owns audit logs and database services.
-- All statements are idempotent so this is a no-op on fresh installs.
ALTER TABLE public.users
DROP COLUMN IF EXISTS enabled,
DROP COLUMN IF EXISTS force_password_reset,
DROP COLUMN IF EXISTS last_login_at;
DROP TABLE IF EXISTS public.user_roles;
DROP TABLE IF EXISTS public.role_permissions;
DROP TABLE IF EXISTS public.permissions;
DROP TABLE IF EXISTS public.roles;
DROP TABLE IF EXISTS public.password_resets;
DROP TABLE IF EXISTS public.invites;
DROP TABLE IF EXISTS public.sessions;
DROP TABLE IF EXISTS public.audit_log;
DROP TABLE IF EXISTS public.database_connections;
DROP TABLE IF EXISTS public.umami_sync_cache;
-- Legacy filename-tracked migration bookkeeping; goose_db_version supersedes it.
DROP TABLE IF EXISTS public.migrations;
-- +goose Down
-- The dropped schema was dead weight from the APwhy vendor import and is not
-- recreated on rollback.
SELECT 1;