본문으로 건너뛰기
Skillpedia
배포 및 클라우드 (DevOps)33k · #8903

railway-database

하는 일

이 스킬은 Railway 프로젝트에 관리되는 데이터베이스 서비스를 추가합니다. Railway에 앱을 호스팅하며 데이터베이스가 필요하고 제대로 연결되기를 원하는 개발자에게 맞습니다.

사용하는 경우

  • ✓Railway 프로젝트에 Postgres, Redis, MySQL, MongoDB를 추가하라고 요청할 때.
  • ✓이미 Railway에 있는 데이터베이스에 앱을 연결하고 싶을 때.
  • ✓볼륨과 연결 설정을 갖춘 데이터베이스를 만들어야 할 때.

스킬 링크

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/railway/database/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/railway/database/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 Railway 프로젝트에 Postgres를 추가하고, API 서비스에 연결해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 먼저 환경에 데이터베이스가 이미 있는지 확인하고, 없으면 필요한 것을 만든 뒤 배포될 때까지 기다리며, 연결 변수를 서비스에 연결할 수 있습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Railway Database

Add official Railway database services. These are maintained templates with pre-configured volumes, networking, and connection variables.

For non-database templates, see the railway-templates skill.

When to Use

  • User asks to "add a database", "add Postgres", "add Redis", etc.
  • User needs a database for their application
  • User asks about connecting to a database
  • User says "add postgres and connect to my server"
  • User says "wire up the database"

Decision Flow

ALWAYS check for existing databases FIRST before creating.

User mentions database
        │
  Check existing DBs first
  (query env config for source.image)
        │
   ┌────┴────┐
 Exists    Doesn't exist
    │           │
    │      Create database
    │      (CLI or API)
    │           │
    │      Wait for deployment
    │           │
    └─────┬─────┘
          │
    User wants to
    connect service?
          │
    ┌─────┴─────┐
   Yes         No
    │           │
Wire vars    Done +
via env     suggest wiring
skill

Check for Existing Databases

Before creating a database, check if one already exists.

For full environment config structure, see environment-config.md.

railway status --json

Then query environment config and check source.image for each service:

query environmentConfig($environmentId: String!) {
  environment(id: $environmentId) {
    config(decryptVariables: false)
  }
}

The config.services object contains each service's configuration. Check source.image for:

  • ghcr.io/railway/postgres* or postgres:* → Postgres
  • ghcr.io/railway/redis* or redis:* → Redis
  • ghcr.io/railway/mysql* or mysql:* → MySQL
  • ghcr.io/railway/mongo* or mongo:* → MongoDB

Available Databases

Database Template Code
PostgreSQL postgres
Redis redis
MySQL mysql
MongoDB mongodb

Prerequisites

Get project context:

railway status --json

Extract:

  • id - project ID
  • environments.edges[0].node.id - environment ID

Get workspace ID (not in status output):

bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'query getWorkspace($projectId: String!) {
    project(id: $projectId) { workspaceId }
  }' \
  '{"projectId": "PROJECT_ID"}'
SCRIPT

Adding a Database

Step 1: Fetch Template

bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'query template($code: String!) {
    template(code: $code) {
      id
      name
      serializedConfig
    }
  }' \
  '{"code": "postgres"}'
SCRIPT

This returns the template's id and serializedConfig needed for deployment.

Step 2: Deploy Template

bash <<'SCRIPT'
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'mutation deployTemplate($input: TemplateDeployV2Input!) {
    templateDeployV2(input: $input) {
      projectId
      workflowId
    }
  }' \
  '{
    "input": {
      "templateId": "TEMPLATE_ID",
      "serializedConfig": SERIALIZED_CONFIG,
      "projectId": "PROJECT_ID",
      "environmentId": "ENVIRONMENT_ID",
      "workspaceId": "WORKSPACE_ID"
    }
  }'
SCRIPT

Important: serializedConfig is the exact object from the template query, not a string.

Connecting to the Database

After deployment, other services connect using reference variables.

For complete variable reference syntax and wiring patterns, see variables.md.

Backend Services (Server-side)

Use the private/internal URL for server-to-server communication:

Database Variable Reference
PostgreSQL ${{Postgres.DATABASE_URL}}
Redis ${{Redis.REDIS_URL}}
MySQL ${{MySQL.MYSQL_URL}}
MongoDB ${{MongoDB.MONGO_URL}}

Frontend Applications

Important: Frontends run in the user's browser and cannot access Railway's private network. They must use public URLs or go through a backend API.

For direct database access from frontend (not recommended):

  • Use the public URL variables (e.g., ${{MongoDB.MONGO_PUBLIC_URL}})
  • Requires TCP proxy to be enabled

Better pattern: Frontend → Backend API → Database

Example: Add PostgreSQL

bash <<'SCRIPT'
# 1. Get context
railway status --json
# Extract project.id and environment.id

# 2. Get workspace ID
${CLAUDE_PLUGIN_ROOT}/skills/lib/railway-api.sh \
  'query { project(id: "proj-id") { workspaceId } 
자주 묻는 질문

중복 데이터베이스를 만드나요?

아니요. 무엇이든 만들기 전에 기존 데이터베이스를 먼저 확인합니다.

어떤 데이터베이스를 지원하나요?

공식 Railway 템플릿을 사용하는 Postgres, Redis, MySQL, MongoDB를 지원합니다.

다른 템플릿은 어떤가요?

Ghost나 n8n 같은 데이터베이스가 아닌 템플릿은 별도의 Railway 템플릿 스킬에 속한다고 밝힙니다.

상세 정보

작성자의 원본 설명

Add official Railway database services (Postgres, Redis, MySQL, MongoDB). Use when user wants to add a database, says "add postgres", "add redis", "add database", "connect to database", or "wire up the database". For other templates (Ghost, Strapi, n8n), use the railway-templates skill.

repo: davila7/claude-code-templates

인기도

GitHub 스타
33k
순위
#8903
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬