Skip to content
do-platform-neon logo

do-platform-neon: Neon Serverless PostgreSQL ์ „๋ฌธ๊ฐ€

do-platform-neon

Neon serverless PostgreSQL ์ „๋ฌธ๊ฐ€ - auto-scaling, database branching, PITR, connection pooling ์ง€์›. serverless ์•ฑ์—์„œ PostgreSQL ํ•„์š”์‹œ ์‚ฌ์šฉ

majiayu000/claude-skill-registry0installs663stars

SKILL.md

Full skill instructions

do-platform-neon: Neon Serverless PostgreSQL ์ „๋ฌธ๊ฐ€

ํ•ต์‹ฌ ์—ญ๋Ÿ‰

Neon Serverless PostgreSQL ์ „๋ฌธ ์ง€์‹: auto-scaling, scale-to-zero ์ปดํ“จํŠธ, database branching, Point-in-Time Recovery, ์ตœ์‹  ORM ํ†ตํ•ฉ์„ ์œ„ํ•œ ์ „๋ฌธํ™”๋œ ์ง€์‹ ์ œ๊ณต

์ฃผ์š” ๊ธฐ๋Šฅ

  • Serverless Compute: auto-scaling PostgreSQL + scale-to-zero๋กœ ๋น„์šฉ ์ตœ์ ํ™”
  • Database Branching: dev, staging, preview ํ™˜๊ฒฝ์šฉ instant copy-on-write ๋ธŒ๋žœ์น˜
  • Point-in-Time Recovery: 30์ผ PITR๋กœ ๋ชจ๋“  ํƒ€์ž„์Šคํƒฌํ”„์— ์ฆ‰์‹œ ๋ณต์›
  • Connection Pooling: serverless ๋ฐ edge ํ˜ธํ™˜ ๋‚ด์žฅ connection pooler
  • PostgreSQL 16: ์ „์ฒด PostgreSQL 16 ํ˜ธํ™˜์„ฑ ๋ฐ extension ์ง€์›

๋น ๋ฅธ ์˜์‚ฌ๊ฒฐ์ • ๊ฐ€์ด๋“œ

  • serverless PostgreSQL + auto-scaling ํ•„์š”? Neon ์„ ํƒ
  • CI/โ€‹CD์šฉ database branching ํ•„์š”? Neon branching ํ™œ์šฉ
  • edge ํ˜ธํ™˜ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ•„์š”? Neon + connection pooling
  • instant preview ํ™˜๊ฒฝ ํ•„์š”? PR๋‹น Neon branch ์ƒ์„ฑ

Context7 ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋งคํ•‘

Neon: /โ€‹neondatabase/โ€‹neon


๊ตฌํ˜„ ๊ฐ€์ด๋“œ

์„ค์ • ๋ฐ ๊ตฌ์„ฑ

ํŒจํ‚ค์ง€ ์„ค์น˜:

npm install @neondatabase/โ€‹serverless
npm install drizzle-orm  # Optional: Drizzle ORM
npm install @prisma/โ€‹client prisma  # Optional: Prisma ORM

ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ •:

# Direct connection (migrations์šฉ)
DATABASE_URL=postgresql://user:[email protected]/โ€‹dbname?sslmode=require

# Pooled connection (serverless/โ€‹edge์šฉ)
DATABASE_URL_POOLED=postgresql://user:[email protected]/โ€‹dbname?sslmode=require

# Neon API (branching์šฉ)
NEON_API_KEY=neon_api_key_xxx
NEON_PROJECT_ID=project-xxx

Serverless ๋“œ๋ผ์ด๋ฒ„ ์‚ฌ์šฉ๋ฒ•

๊ธฐ๋ณธ ์ฟผ๋ฆฌ ์‹คํ–‰:

import { neon } from '@neondatabase/โ€‹serverless'

const sql = neon(process.env.DATABASE_URL!)

// ๊ฐ„๋‹จํ•œ ์ฟผ๋ฆฌ
const users = await sql`SELECT * FROM users WHERE active = true`

// ํŒŒ๋ผ๋ฏธํ„ฐํ™”๋œ ์ฟผ๋ฆฌ (SQL injection ๋ฐฉ์ง€)
const userId = 'user-123'
const user = await sql`SELECT * FROM users WHERE id = ${userId}`

// ํŠธ๋žœ์žญ์…˜ ์ง€์›
const result = await sql.transaction([
  sql`UPDATE accounts SET balance = balance - 100 WHERE id = ${fromId}`,
  sql`UPDATE accounts SET balance = balance + 100 WHERE id = ${toId}`
])

์„ธ์…˜ ์ง€์†์„ฑ์„ ์œ„ํ•œ WebSocket ์—ฐ๊ฒฐ:

import { Pool, neonConfig } from '@neondatabase/โ€‹serverless'
import ws from 'ws'

// Node.js ํ™˜๊ฒฝ์—์„œ ํ•„์ˆ˜
neonConfig.webSocketConstructor = ws

const pool = new Pool({ connectionString: process.env.DATABASE_URL })

// ์„ธ์…˜ ๊ธฐ๋ฐ˜ ์ž‘์—…์— pool ์‚ฌ์šฉ
const client = await pool.connect()
try {
  await client.query('BEGIN')
  await client.query('INSERT INTO logs (message) VALUES ($1)', ['Action'])
  await client.query('COMMIT')
} finally {
  client.release()
}

Database Branching

Branch ๊ด€๋ฆฌ API:

class NeonBranchManager {
  private apiKey: string
  private projectId: string
  private baseUrl = 'https://console.neon.tech/โ€‹api/โ€‹v2'

  constructor(apiKey: string, projectId: string) {
    this.apiKey = apiKey
    this.projectId = projectId
  }

  private async request(path: string, options: RequestInit = {}) {
    const response = await fetch(`${this.baseUrl}${path}`, {
      ...options,
      headers: {
        'Authorization': `Bearer ${this.apiKey}`,
        'Content-Type': 'application/โ€‹json',
        ...options.headers
      }
    })
    if (!response.ok) throw new Error(`Neon API error: ${response.statusText}`)
    return response.json()
  }

  async createBranch(name: string, parentId: string = 'main') {
    return this.request(`/โ€‹projects/โ€‹${this.projectId}/โ€‹branches`, {
      method: 'POST',
      body: JSON.stringify({
        branch: { name, parent_id: parentId }
      })
    })
  }

  async deleteBranch(branchId: string) {
    return this.request(`/โ€‹projects/โ€‹${this.projectId}/โ€‹branches/โ€‹${branchId}`, {
      method: 'DELETE'
    })
  }

  async listBranches() {
    return this.request(`/โ€‹projects/โ€‹${this.projectId}/โ€‹branches`)
  }

  async getBranchConnectionString(branchId: string) {
    const endpoints = await this.request(
      `/โ€‹projects/โ€‹${this.projectId}/โ€‹branches/โ€‹${branchId}/โ€‹endpoints`
    )
    return endpoints.endpoints[0]?.connection_uri
  }
}

Pull Request์šฉ Preview Branch:

async function createPreviewEnvironment(prNumber: number) {
  const branchManager = new NeonBranchManager(
    process.env.NEON_API_KEY!,
    process.env.NEON_PROJECT_ID!
  )

  // main์—์„œ branch ์ƒ์„ฑ
  const branch = await branchManager.createBranch(`pr-${prNumber}`, 'main')

  // connection string ํš๋“
  const connectionString = await branchManager.getBranchConnectionString(branch.branch.id)

  return {
    branchId: branch.branch.id,
    branchName: branch.branch.name,
    connectionString
  }
}

async function cleanupPreviewEnvironment(branchId: string) {
  const branchManager = new NeonBranchManager(
    process.env.NEON_API_KEY!,
    process.env.NEON_PROJECT_ID!
  )
  await branchManager.deleteBranch(branchId)
}

Point-in-Time Recovery

ํŠน์ • ์‹œ์ ์œผ๋กœ ๋ณต์›:

async function restoreToPoint(timestamp: Date) {
  const response = await fetch(
    `https://console.neon.tech/โ€‹api/โ€‹v2/โ€‹projects/โ€‹${process.env.NEON_PROJECT_ID}/โ€‹branches`,
    {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.NEON_API_KEY}`,
        'Content-Type': 'application/โ€‹json'
      },
      body: JSON.stringify({
        branch: {
          name: `restore-${timestamp.toISOString().replace(/[:.]/โ€‹g, '-')}`,
          parent_id: 'main',
          parent_timestamp: timestamp.toISOString()
        }
      })
    }
  )

  return response.json()
}

// ์‚ฌ์šฉ ์˜ˆ์‹œ: 1์‹œ๊ฐ„ ์ „์œผ๋กœ ๋ณต์›
const oneHourAgo = new Date(Date.now() - 60 * 60 * 1000)
const restoredBranch = await restoreToPoint(oneHourAgo)

Drizzle ORM ํ†ตํ•ฉ

์Šคํ‚ค๋งˆ ์ •์˜:

// schema.ts
import { pgTable, uuid, text, timestamp, boolean, jsonb } from 'drizzle-orm/โ€‹pg-core'

export const users = pgTable('users', {
  id: uuid('id').primaryKey().defaultRandom(),
  email: text('email').notNull().unique(),
  name: text('name'),
  createdAt: timestamp('created_at').defaultNow(),
  metadata: jsonb('metadata')
})

export const projects = pgTable('projects', {
  id: uuid('id').primaryKey().defaultRandom(),
  name: text('name').notNull(),
  ownerId: uuid('owner_id').references(() => users.id),
  isPublic: boolean('is_public').default(false),
  createdAt: timestamp('created_at').defaultNow()
})

Drizzle ํด๋ผ์ด์–ธํŠธ ์„ค์ •:

// db.ts
import { neon } from '@neondatabase/โ€‹serverless'
import { drizzle } from 'drizzle-orm/โ€‹neon-http'
import * as schema from './โ€‹schema'

const sql = neon(process.env.DATABASE_URL!)
export const db = drizzle(sql, { schema })

// ์ฟผ๋ฆฌ ์˜ˆ์‹œ
const allUsers = await db.select().from(schema.users)

const userProjects = await db
  .select()
  .from(schema.projects)
  .where(eq(schema.projects.ownerId, userId))
  .orderBy(desc(schema.projects.createdAt))

Prisma ORM ํ†ตํ•ฉ

Prisma ์Šคํ‚ค๋งˆ:

// schema.prisma
generator client {
  provider = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id        String    @id @default(uuid())
  email     String    @unique
  name      String?
  projects  Project[]
  createdAt DateTime  @default(now())
}

model Project {
  id        String   @id @default(uuid())
  name      String
  owner     User     @relation(fields: [ownerId], references: [id])
  ownerId   String
  isPublic  Boolean  @default(false)
  createdAt DateTime @default(now())
}

Prisma + Neon Serverless ๋“œ๋ผ์ด๋ฒ„:

// db.ts
import { Pool, neonConfig } from '@neondatabase/โ€‹serverless'
import { PrismaNeon } from '@prisma/โ€‹adapter-neon'
import { PrismaClient } from '@prisma/โ€‹client'

neonConfig.webSocketConstructor = require('ws')

const pool = new Pool({ connectionString: process.env.DATABASE_URL })
const adapter = new PrismaNeon(pool)
export const prisma = new PrismaClient({ adapter })

// ์ฟผ๋ฆฌ ์˜ˆ์‹œ
const users = await prisma.user.findMany({
  include: { projects: true }
})

๊ณ ๊ธ‰ ํŒจํ„ด

Edge์šฉ Connection Pooling

Edge Function ์„ค์ •:

import { neon } from '@neondatabase/โ€‹serverless'

// edge ํ™˜๊ฒฝ์—์„œ๋Š” pooled connection ์‚ฌ์šฉ
const sql = neon(process.env.DATABASE_URL_POOLED!)

export const config = {
  runtime: 'edge'
}

export default async function handler(request: Request) {
  const users = await sql`SELECT id, name FROM users LIMIT 10`
  return Response.json(users)
}

CI/โ€‹CD Branch ์ž๋™ํ™”

GitHub Actions ํ†ตํ•ฉ:

name: Preview Environment

on:
  pull_request:
    types: [opened, synchronize, closed]

jobs:
  create-preview:
    if: github.event.action != 'closed'
    runs-on: ubuntu-latest
    steps:
      - name: Create Neon Branch
        id: create-branch
        run: |
          BRANCH=$(curl -s -X POST \
            -H "Authorization: Bearer ${{ secrets.NEON_API_KEY }}" \
            -H "Content-Type: application/โ€‹json" \
            -d '{"branch":{"name":"pr-${{ github.event.number }}"}}' \
            "https://console.neon.tech/โ€‹api/โ€‹v2/โ€‹projects/โ€‹${{ secrets.NEON_PROJECT_ID }}/โ€‹branches")
          echo "branch_id=$(echo $BRANCH | jq -r '.branch.id')" >> $GITHUB_OUTPUT

  cleanup-preview:
    if: github.event.action == 'closed'
    runs-on: ubuntu-latest
    steps:
      - name: Delete Neon Branch
        run: |
          curl -X DELETE \
            -H "Authorization: Bearer ${{ secrets.NEON_API_KEY }}" \
            "https://console.neon.tech/โ€‹api/โ€‹v2/โ€‹projects/โ€‹${{ secrets.NEON_PROJECT_ID }}/โ€‹branches/โ€‹pr-${{ github.event.number }}"

Auto-Scaling ์„ค์ •

API๋ฅผ ํ†ตํ•œ ์ปดํ“จํŠธ ์„ค์ •:

async function configureAutoScaling(endpointId: string) {
  const response = await fetch(
    `https://console.neon.tech/โ€‹api/โ€‹v2/โ€‹projects/โ€‹${process.env.NEON_PROJECT_ID}/โ€‹endpoints/โ€‹${endpointId}`,
    {
      method: 'PATCH',
      headers: {
        'Authorization': `Bearer ${process.env.NEON_API_KEY}`,
        'Content-Type': 'application/โ€‹json'
      },
      body: JSON.stringify({
        endpoint: {
          autoscaling_limit_min_cu: 0.25,  // Scale to zero
          autoscaling_limit_max_cu: 4,     // ์ตœ๋Œ€ 4 compute units
          suspend_timeout_seconds: 300     // 5๋ถ„ ์œ ํœด ํ›„ ์ค‘๋‹จ
        }
      })
    }
  )
  return response.json()
}

๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ์›Œํฌํ”Œ๋กœ์šฐ

๊ฐœ๋ฐœ์—์„œ ํ”„๋กœ๋•์…˜์œผ๋กœ:

// direct connection์—์„œ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ์‹คํ–‰ (pooled ์•„๋‹˜)
import { migrate } from 'drizzle-orm/โ€‹neon-http/โ€‹migrator'
import { neon } from '@neondatabase/โ€‹serverless'
import { drizzle } from 'drizzle-orm/โ€‹neon-http'

async function runMigrations() {
  // ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์—๋Š” direct connection ์‚ฌ์šฉ
  const sql = neon(process.env.DATABASE_URL!)
  const db = drizzle(sql)

  await migrate(db, { migrationsFolder: './โ€‹drizzle' })
  console.log('Migrations completed')
}

ํ”„๋กœ๋ฐ”์ด๋” ์„ ํƒ ๊ฐ€์ด๋“œ

Neon ์‚ฌ์šฉ ๊ถŒ์žฅ ์ƒํ™ฉ

  • Serverless ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜: auto-scaling๊ณผ scale-to-zero๋กœ ๋น„์šฉ ์ ˆ๊ฐ
  • Preview ํ™˜๊ฒฝ: instant branching์œผ๋กœ PR๋‹น ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ œ๊ณต
  • Edge ๋ฐฐํฌ: connection pooling์ด edge runtime๊ณผ ํ˜ธํ™˜
  • ๊ฐœ๋ฐœ ์›Œํฌํ”Œ๋กœ์šฐ: ํ”„๋กœ๋•์…˜์—์„œ branchํ•˜์—ฌ ์‹ค์ œ ๊ฐœ๋ฐœ ๋ฐ์ดํ„ฐ ์‚ฌ์šฉ
  • ๋น„์šฉ ์ตœ์ ํ™”: ํ™œ์„ฑ ์ปดํ“จํŠธ ์‹œ๊ฐ„์—๋งŒ ๋น„์šฉ ๋ฐœ์ƒ

๋Œ€์•ˆ ๊ณ ๋ ค ์ƒํ™ฉ

  • Vector Search ํ•„์š”: pgvector๊ฐ€ ์žˆ๋Š” Supabase ๊ณ ๋ ค
  • Real-time Subscription ํ•„์š”: Supabase ๋˜๋Š” Convex ๊ณ ๋ ค
  • NoSQL ์œ ์—ฐ์„ฑ ํ•„์š”: Firestore ๋˜๋Š” Convex ๊ณ ๋ ค
  • ๋‚ด์žฅ Auth ํ•„์š”: Supabase ๊ณ ๋ ค

๊ฐ€๊ฒฉ ์ฐธ๊ณ  (2024)

  • Free Tier: 3GB ์Šคํ† ๋ฆฌ์ง€, ์›” 100 compute hours
  • Pro Tier: ์‚ฌ์šฉ๋Ÿ‰ ๊ธฐ๋ฐ˜ ๊ฐ€๊ฒฉ, ์ถ”๊ฐ€ ์Šคํ† ๋ฆฌ์ง€ ๋ฐ ์ปดํ“จํŠธ
  • Scale-to-Zero: ์œ ํœด ๊ธฐ๊ฐ„ ์ค‘ ๋น„์šฉ ๋ฏธ๋ฐœ์ƒ

๊ด€๋ จ ์Šคํ‚ฌ

  • do-platform-supabase: RLS ๋˜๋Š” pgvector ํ•„์š”์‹œ ๋Œ€์•ˆ
  • do-lang-typescript: Drizzle ๋ฐ Prisma์šฉ TypeScript ํŒจํ„ด
  • do-domain-backend: ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ†ตํ•ฉ ๋ฐฑ์—”๋“œ ์•„ํ‚คํ…์ฒ˜

Status: Production Ready Generated with: Do Skill Factory v2.0 Last Updated: 2025-12-07 Technology: Neon Serverless PostgreSQL

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgรคnger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View