Initialize a PostgreSQL database and user on any configured host
Create a new PostgreSQL database and user with sane defaults on any configured host.
If parameters are missing from $ARGUMENTS, use mcp_question to gather them:
mcp_question({
questions: [
{
question: "Which PostgreSQL host should the database be created on?",
header: "Host",
options: [
{ label: "pilaster (Recommended)", description: "Main web services host" },
{ label: "monolith", description: "Infrastructure services" },
{ label: "zenith", description: "AI/GPU workloads" },
{ label: "chassis", description: "AI development workstation" },
{ label: "tty-ruinous-social", description: "Cloud VPS" }
]
},
{
question: "What should the database be named? (Also used as username)",
header: "DB Name",
options: [
{ label: "Enter name...", description: "e.g., myservice, n8n, wikijs" }
]
}
]
})
Expected $ARGUMENTS format: <hostname> <db_name>
pilaster myservicezenith openwebuiThe skill uses these environment variables from .envrc.local to connect:
| Host | Environment Variable |
|------|---------------------|
| pilaster | PILASTER_POSTGRES_DATABASE_URI |
| monolith | MONOLITH_POSTGRES_DATABASE_URI |
| zenith | ZENITH_POSTGRES_DATABASE_URI |
| chassis | CHASSIS_POSTGRES_DATABASE_URI |
| tty-ruinous-social | TTY_RUINOUS_SOCIAL_POSTGRES_DATABASE_URI |
Based on hostname, select the appropriate MCP postgres tool:
pilaster → mcp_postgres-pilaster_querymonolith → mcp_postgres-monolith_queryzenith → mcp_postgres-zenith_querytty-ruinous-social → Not available via MCP (use SSH)openssl rand -base64 24 | tr -d '/+=' | head -c 20
Run each SQL statement separately using the appropriate MCP tool:
CREATE DATABASE <db_name>;
CREATE USER <db_name> WITH PASSWORD '<generated_password>';
GRANT ALL PRIVILEGES ON DATABASE <db_name> TO <db_name>;
Connect to the new database and grant schema permissions:
-- This requires connecting to the new database
-- For MCP tools, this may need to be done via the container
GRANT ALL ON SCHEMA public TO <db_name>;
Note: The MCP postgres tools connect to the postgres database. To grant schema permissions on the new database, you may need to:
\c <db_name> if the tool supports it, ORssh <hostname> "docker exec -i postgres psql -U postgres -d <db_name> -c 'GRANT ALL ON SCHEMA public TO <db_name>;'"Provide the connection string in multiple formats:
For Docker containers (internal network):
DATABASE_URL=postgresql://<db_name>:<password>@postgres:5432/<db_name>
For external access (via hostname):
DATABASE_URL=postgresql://<db_name>:<password>@<hostname>.meskill.farm:5432/<db_name>
servicenet and datanet networksdependsOn = ["postgres"]; to container definition/encrypt-secret| Host | Internal Hostname | Port | Notes | |------|-------------------|------|-------| | pilaster | postgres | 5432 | Main web services | | monolith | postgres | 5432 | Infrastructure | | zenith | postgres | 5432 | AI workloads | | tty-ruinous-social | postgres | 5432 | Cloud VPS |
# Create database on pilaster
/initialize-pgdb pilaster rallly
# Create database on zenith for AI service
/initialize-pgdb zenith openwebui
# Create database on monolith
/initialize-pgdb monolith gatus
✅ Database created successfully!
Host: pilaster
Database: rallly
Username: rallly
Password: xK7mN2pQ9rT4vW6y
Connection Strings:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Docker (internal):
DATABASE_URL=postgresql://rallly:xK7mN2pQ9rT4vW6y@postgres:5432/rallly
External:
DATABASE_URL=postgresql://rallly:xK7mN2pQ9rT4vW6y@pilaster.meskill.farm:5432/rallly
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Next steps:
1. Add to container networks: ["servicenet", "datanet"]
2. Add dependency: dependsOn = ["postgres"];
3. Encrypt credentials: /encrypt-secret hosts/pilaster/files/docker/env/rallly.env.age
-- Check if database exists
SELECT datname FROM pg_database WHERE datname = '<db_name>';
-- Drop if needed (CAREFUL!)
DROP DATABASE <db_name>;
DROP USER <db_name>;
-- Check existing users
SELECT usename FROM pg_user WHERE usename = '<db_name>';
-- Update password instead
ALTER USER <db_name> WITH PASSWORD '<new_password>';
.envrc.localSearch for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer