neon-database
在使用Neon无服务器PostgreSQL数据库时使用。涵盖数据库设置、CLI命令、Drizzle ORM集成、模式迁移、连接池以及用于身份验证和聊天历史的用户数据存储模式。
📖 中文导读:在使用Neon无服务器PostgreSQL数据库时使用。涵盖数据库设置、CLI命令、Drizzle ORM集成、模式迁移、连接池以及用于身份验证和聊天历史的用户数据存储模式。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: neon-database description: Use when working with Neon serverless PostgreSQL database. Covers database setup, CLI commands, Drizzle ORM integration, schema migrations, connection pooling, and user data storage patterns for authentication and chat history.
Neon Database Skill
Quick Start Workflow
When working with Neon PostgreSQL:
Check if database exists
- Look in
.envor.env.localforDATABASE_URL - Verify connection with
neon connection-string
- Look in
For schema changes
- Always use Drizzle migrations (never manual SQL)
- Check
drizzle.config.tsis configured - Generate migration:
drizzle-kit generate - Apply migration:
drizzle-kit push
For user data storage
- Use
userstable for authentication - Use
sessionstable for session management - Use
chat_historytable for conversations - Always include
user_idforeign key
- Use
For queries
- Use Drizzle ORM for type safety
- Implement proper error handling
- Use transactions for multi-table operations
Standard Patterns
Environment Variables
DATABASE_URL="postgresql://user:pass@ep-xxx.us-east-2.aws.neon.tech/neondb?sslmode=require"
Connection Setup
import { drizzle } from 'drizzle-orm/neon-http';
import { neon } from '@neondatabase/serverless';
const sql = neon(process.env.DATABASE_URL!);
export const db = drizzle(sql);
Database Design Principles
For this Physical AI RAG chatbot:
- Users table: Store authentication data (email, password_hash, email_verified)
- Sessions table: Manage user sessions (connect to users via user_id)
- Chat history table: Store Q&A pairs with user attribution
- All timestamps: Use
timestamp('created_at').defaultNow() - All IDs: Use
text('id').primaryKey()withcrypto.randomUUID()
Knowledge Base
For detailed information, check these references:
- CLI Commands →
references/neon-cli.md - Drizzle ORM Setup →
references/drizzle-orm.md - Schema Patterns →
references/database-schemas.md - Query Examples →
references/query-patterns.md - Migrations Guide →
references/migrations.md