mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 15:51:26 +00:00
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:
1 parent
37a56dc6b6
commit
9e3aa3aa17
153 files changed
+6996
-11135
No files matched your search
+87
-10
@@ -25,19 +25,33 @@ CREATE TABLE environments (
|
||||
);
|
||||
|
||||
CREATE TABLE services (
|
||||
id UUID PRIMARY KEY,
|
||||
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
name VARCHAR(255) NOT NULL,
|
||||
type VARCHAR(50) NOT NULL,
|
||||
status VARCHAR(50) NOT NULL,
|
||||
image TEXT,
|
||||
command TEXT,
|
||||
environment VARCHAR(50) DEFAULT 'production',
|
||||
cpu VARCHAR(20) DEFAULT '0.5',
|
||||
memory VARCHAR(20) DEFAULT '512Mi',
|
||||
description TEXT,
|
||||
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
||||
environment_id UUID NOT NULL REFERENCES environments(id) ON DELETE CASCADE,
|
||||
service_type VARCHAR(50) NOT NULL,
|
||||
source_type VARCHAR(50) NOT NULL,
|
||||
source_url VARCHAR(500),
|
||||
image_name VARCHAR(500),
|
||||
build_command TEXT,
|
||||
start_command TEXT,
|
||||
cpu_limit INTEGER,
|
||||
memory_limit INTEGER,
|
||||
public_url VARCHAR(500),
|
||||
health_check_url VARCHAR(500),
|
||||
status VARCHAR(50) DEFAULT 'created',
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
UNIQUE(project_id, name)
|
||||
type VARCHAR(50),
|
||||
image VARCHAR(500),
|
||||
command TEXT,
|
||||
environment VARCHAR(50),
|
||||
git_repo VARCHAR(500),
|
||||
git_branch VARCHAR(100),
|
||||
build_path VARCHAR(500),
|
||||
cpu VARCHAR(50),
|
||||
memory VARCHAR(50)
|
||||
);
|
||||
|
||||
CREATE TABLE deployments (
|
||||
@@ -95,3 +109,66 @@ CREATE TABLE database_backups (
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
completed_at TIMESTAMP WITH TIME ZONE
|
||||
);
|
||||
|
||||
CREATE TABLE node_agents (
|
||||
id VARCHAR(255) PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
hostname VARCHAR(255) NOT NULL,
|
||||
ip_address VARCHAR(45) NOT NULL,
|
||||
port INTEGER NOT NULL,
|
||||
status VARCHAR(50) DEFAULT 'offline',
|
||||
version VARCHAR(50),
|
||||
capabilities JSONB,
|
||||
resources JSONB,
|
||||
last_heartbeat TIMESTAMP WITH TIME ZONE,
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
metadata JSONB
|
||||
);
|
||||
|
||||
CREATE TABLE container_instances (
|
||||
id VARCHAR(255) PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
image VARCHAR(255) NOT NULL,
|
||||
project_id VARCHAR(255) NOT NULL,
|
||||
service_id VARCHAR(255) NOT NULL,
|
||||
node_agent_id VARCHAR(255) NOT NULL REFERENCES node_agents(id) ON DELETE CASCADE,
|
||||
status JSONB,
|
||||
resources JSONB,
|
||||
ports JSONB,
|
||||
environment JSONB,
|
||||
volumes JSONB,
|
||||
networks JSONB,
|
||||
restart_policy JSONB,
|
||||
health_check JSONB,
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
started_at TIMESTAMP WITH TIME ZONE,
|
||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE agent_commands (
|
||||
id VARCHAR(255) PRIMARY KEY,
|
||||
type VARCHAR(100) NOT NULL,
|
||||
node_agent_id VARCHAR(255) NOT NULL REFERENCES node_agents(id) ON DELETE CASCADE,
|
||||
container_id VARCHAR(255) REFERENCES container_instances(id) ON DELETE CASCADE,
|
||||
payload JSONB,
|
||||
status VARCHAR(50) DEFAULT 'pending',
|
||||
result TEXT,
|
||||
error TEXT,
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
||||
completed_at TIMESTAMP WITH TIME ZONE
|
||||
);
|
||||
|
||||
CREATE TABLE agent_heartbeats (
|
||||
id VARCHAR(255) PRIMARY KEY,
|
||||
node_agent_id VARCHAR(255) NOT NULL REFERENCES node_agents(id) ON DELETE CASCADE,
|
||||
timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
status VARCHAR(50) NOT NULL DEFAULT 'unknown',
|
||||
resources JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
container_count INTEGER NOT NULL DEFAULT 0,
|
||||
system_load JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
uptime BIGINT NOT NULL DEFAULT 0,
|
||||
version VARCHAR(50) NOT NULL DEFAULT '',
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
Reference in new issue
Block a user