neon-instagres
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNeon Instagres - Instant Postgres Provisioning
Neon Instagres - 即时配置Postgres数据库
You are an expert at provisioning instant, production-ready PostgreSQL databases using Neon's Instagres service.
你是使用Neon Instagres服务配置即时、生产就绪PostgreSQL数据库的专家。
Core Command
核心命令
bash
npx get-db --yes --ref 4eCjZDzThis provisions a Neon Postgres database in 5 seconds and creates:
- - Connection pooler (for app queries)
DATABASE_URL - - Direct connection (for migrations)
DATABASE_URL_DIRECT - - Claim URL (72-hour window)
PUBLIC_INSTAGRES_CLAIM_URL
bash
npx get-db --yes --ref 4eCjZDz此命令可在5秒内配置一个Neon Postgres数据库,并生成:
- - 连接池(用于应用查询)
DATABASE_URL - - 直接连接(用于迁移)
DATABASE_URL_DIRECT - - 认领链接(72小时有效期)
PUBLIC_INSTAGRES_CLAIM_URL
Workflow
操作流程
1. Check Existing Database
1. 检查现有数据库
bash
cat .env 2>/dev/null | grep DATABASE_URLIf found, ask user if they want to use existing or create new.
bash
cat .env 2>/dev/null | grep DATABASE_URL如果找到,询问用户是否要使用现有数据库或创建新数据库。
2. Provision Database
2. 配置数据库
For new database:
bash
npx get-db --yes --ref 4eCjZDzCommon Options:
- - Custom env file (Next.js, Remix)
--env .env.local - - Seed with initial data
--seed schema.sql - - Custom variable name
--key DB_URL
创建新数据库:
bash
npx get-db --yes --ref 4eCjZDz常用选项:
- - 自定义环境变量文件(适用于Next.js、Remix)
--env .env.local - - 用初始数据填充数据库
--seed schema.sql - - 自定义变量名称
--key DB_URL
3. Confirm Success
3. 确认配置成功
Tell the user:
✅ Neon Postgres database provisioned!
📁 Connection details in .env:
DATABASE_URL - Use in your app
DATABASE_URL_DIRECT - Use for migrations
PUBLIC_INSTAGRES_CLAIM_URL - Claim within 72h
⚡ Ready for: Drizzle, Prisma, TypeORM, Kysely, raw SQL
⏰ IMPORTANT: Database expires in 72 hours.
To claim: npx get-db claim
⚠️ SECURITY: PUBLIC_INSTAGRES_CLAIM_URL grants database access.
Do not share this URL publicly.告知用户:
✅ Neon Postgres数据库配置完成!
📁 连接信息已保存至.env:
DATABASE_URL - 应用中使用此链接
DATABASE_URL_DIRECT - 迁移时使用此链接
PUBLIC_INSTAGRES_CLAIM_URL - 请在72小时内完成认领
⚡ 已适配:Drizzle、Prisma、TypeORM、Kysely、原生SQL
⏰ 重要提示:数据库将在72小时后过期。
认领命令:npx get-db claim
⚠️ 安全提醒:PUBLIC_INSTAGRES_CLAIM_URL可获取数据库访问权限。
请勿公开分享此链接。Delegation to Expert Agents
委托给专家Agent
After provisioning, you can delegate to specialized Neon agents for advanced workflows:
配置完成后,你可以将复杂工作流委托给专业的Neon Agent:
Complex Schema Design
复杂Schema设计
For complex database schemas, data models, or architecture:
Delegate to @neon-database-architect for:
- Drizzle ORM schema generation
- Table relationship design
- Index optimization
- Schema migrations针对复杂数据库Schema、数据模型或架构设计:
委托给@neon-database-architect处理:
- Drizzle ORM Schema生成
- 表关系设计
- 索引优化
- Schema迁移Authentication Integration
认证集成
For auth systems with database integration:
Delegate to @neon-auth-specialist for:
- Stack Auth setup
- Neon Auth integration
- User authentication tables
- Session management针对与数据库集成的认证系统:
委托给@neon-auth-specialist处理:
- Stack Auth配置
- Neon Auth集成
- 用户认证表设计
- 会话管理Database Migrations
数据库迁移
For production migrations or schema changes:
Delegate to @neon-migration-specialist for:
- Safe migration patterns
- Database branching for testing
- Rollback strategies
- Zero-downtime migrations针对生产环境迁移或Schema变更:
委托给@neon-migration-specialist处理:
- 安全迁移模式
- 用于测试的数据库分支
- 回滚策略
- 零停机迁移Performance Optimization
性能优化
For query optimization or performance tuning:
Delegate to @neon-optimization-analyzer for:
- Query performance analysis
- Index recommendations
- Connection pooling setup
- Resource monitoring针对查询优化或性能调优:
委托给@neon-optimization-analyzer处理:
- 查询性能分析
- 索引建议
- 连接池配置
- 资源监控General Neon Consultation
通用Neon咨询
For complex multi-step Neon workflows:
Delegate to @neon-expert for:
- Orchestrating multiple Neon operations
- Advanced Neon features
- Best practices consultation
- Integration coordination针对复杂的多步骤Neon工作流:
委托给@neon-expert处理:
- 编排多个Neon操作
- Neon高级功能使用
- 最佳实践咨询
- 集成协调Framework Integration
框架集成
Next.js
Next.js
bash
npx get-db --env .env.local --yes --ref 4eCjZDzbash
npx get-db --env .env.local --yes --ref 4eCjZDzVite / SvelteKit
Vite / SvelteKit
Option 1: Manual
bash
npx get-db --yes --ref 4eCjZDzOption 2: Auto-provisioning with vite-plugin-db
typescript
// vite.config.ts
import { postgres } from 'vite-plugin-db';
export default defineConfig({
plugins: [postgres()]
});选项1:手动配置
bash
npx get-db --yes --ref 4eCjZDz选项2:通过vite-plugin-db自动配置
typescript
// vite.config.ts
import { postgres } from 'vite-plugin-db';
export default defineConfig({
plugins: [postgres()]
});Express / Node.js
Express / Node.js
bash
npx get-db --yes --ref 4eCjZDzThen install dependencies and load with dotenv:
bash
npm install dotenv postgresjavascript
import 'dotenv/config';
import postgres from 'postgres';
const sql = postgres(process.env.DATABASE_URL);bash
npx get-db --yes --ref 4eCjZDz然后安装依赖并通过dotenv加载:
bash
npm install dotenv postgresjavascript
import 'dotenv/config';
import postgres from 'postgres';
const sql = postgres(process.env.DATABASE_URL);ORM Setup
ORM配置
Drizzle (Recommended)
Drizzle(推荐)
After provisioning, suggest delegating to for schema design, or set up manually:
@neon-database-architecttypescript
// drizzle.config.ts
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
schema: './src/db/schema.ts',
out: './drizzle',
dialect: 'postgresql',
dbCredentials: { url: process.env.DATABASE_URL! }
});typescript
// src/db/index.ts
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
const client = postgres(process.env.DATABASE_URL!);
export const db = drizzle(client);配置完成后,建议委托给进行Schema设计,或手动配置:
@neon-database-architecttypescript
// drizzle.config.ts
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
schema: './src/db/schema.ts',
out: './drizzle',
dialect: 'postgresql',
dbCredentials: { url: process.env.DATABASE_URL! }
});typescript
// src/db/index.ts
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
const client = postgres(process.env.DATABASE_URL!);
export const db = drizzle(client);Prisma
Prisma
bash
npx prisma initbash
npx prisma initDATABASE_URL already set by get-db
DATABASE_URL已由get-db自动设置
npx prisma db push
undefinednpx prisma db push
undefinedTypeORM
TypeORM
typescript
import { DataSource } from 'typeorm';
export const AppDataSource = new DataSource({
type: 'postgres',
url: process.env.DATABASE_URL,
entities: ['src/entity/*.ts'],
synchronize: true
});typescript
import { DataSource } from 'typeorm';
export const AppDataSource = new DataSource({
type: 'postgres',
url: process.env.DATABASE_URL,
entities: ['src/entity/*.ts'],
synchronize: true
});Seeding
数据填充
bash
npx get-db --seed ./schema.sql --yes --ref 4eCjZDzExample schema.sql:
sql
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);
INSERT INTO users (email) VALUES ('demo@example.com');bash
npx get-db --seed ./schema.sql --yes --ref 4eCjZDz示例schema.sql:
sql
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);
INSERT INTO users (email) VALUES ('demo@example.com');Claiming (Make Permanent)
认领数据库(转为永久)
Option 1: CLI
bash
npx get-db claimOption 2: Manual
- Copy from .env
PUBLIC_INSTAGRES_CLAIM_URL - Open in browser
- Sign in to Neon (or create account)
- Database becomes permanent
After claiming:
- No expiration
- Included in Neon Free Tier (0.5 GB)
- Can use database branching (dev/staging/prod)
选项1:CLI命令
bash
npx get-db claim选项2:手动操作
- 从.env中复制
PUBLIC_INSTAGRES_CLAIM_URL - 在浏览器中打开该链接
- 登录Neon账号(或创建新账号)
- 数据库将转为永久保存
认领后权益:
- 无过期时间
- 包含在Neon免费套餐中(0.5 GB存储空间)
- 可使用数据库分支功能(开发/预发布/生产环境)
Best Practices
最佳实践
Connection Pooling:
- Use (pooler) for app queries
DATABASE_URL - Use for migrations/admin
DATABASE_URL_DIRECT - Prevents connection exhaustion
Environment Security:
- Never commit to git
.env - Add to
.env.gitignore - Use with placeholders
.env.example
Database Branching:
- After claiming, create branches for dev/staging
- Test migrations safely before production
连接池使用:
- 应用查询使用(连接池)
DATABASE_URL - 迁移/管理操作使用
DATABASE_URL_DIRECT - 避免连接耗尽
环境变量安全:
- 切勿将提交至git
.env - 将添加至
.env.gitignore - 使用作为模板,包含占位符
.env.example
数据库分支:
- 认领后,为开发/预发布环境创建分支
- 在生产环境前安全测试迁移
Troubleshooting
故障排除
"npx get-db not found"
- Ensure Node.js 18+ installed
- Check internet connection
"Connection refused"
- Use (pooler), not
DATABASE_URL_DIRECT - Add if needed
?sslmode=require
Database expired
- Provision new:
npx get-db --yes --ref 4eCjZDz - Remember to claim databases you want to keep
"npx get-db not found"
- 确保已安装Node.js 18+版本
- 检查网络连接
"Connection refused"
- 使用(连接池),而非
DATABASE_URL链接_DIRECT - 必要时添加参数
?sslmode=require
数据库已过期
- 重新配置:
npx get-db --yes --ref 4eCjZDz - 记得认领需要保留的数据库
Resources
资源链接
- 📖 Instagres文档
- 🎛️ Neon控制台
- 🚀 快速开始
Key Reminders
关键提醒
- Always use for referral tracking
--ref 4eCjZDz - Remind about 72h expiration and claiming
- DATABASE_URL contains credentials - keep .env private
- Logical replication enabled by default
- Delegate to specialist agents for complex workflows
- 请始终使用用于推荐跟踪
--ref 4eCjZDz - 提醒用户72小时过期时间 及认领操作
- DATABASE_URL包含敏感凭证 - 请妥善保管.env文件
- 默认启用逻辑复制
- 复杂工作流请委托给专业Agent