planetscale
它能做什么
PlanetScale 是一项用来管理 MySQL 兼容数据库的服务。它支持安全地创建和修改数据库,还提供开发分支(branching)和零停机更新等功能。
适用场景
- ✓当你需要一个在更新时也不会停机的 MySQL 数据库时。
- ✓当你想在独立环境中测试数据库修改,再决定是否上线时。
- ✓当你要构建一个需要可扩展且可靠的数据库的应用时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/planetscale/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我在 us-east 区域创建一个名为 my-project 的新数据库。”
每周 5 个新技能,1 分钟读完。
工作原理
你可以使用 `pscale` 命令行工具与 PlanetScale 交互。它允许你创建数据库,用类似 Git 的工作流程管理 schema(数据库结构),并安全地部署修改。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
PlanetScale
Use PlanetScale for serverless MySQL-compatible databases with non-blocking schema change workflows built on Vitess.
When to Use
- You need a managed MySQL-compatible database with zero-downtime migrations.
- Your team wants Git-like branching for schema development.
- You are building a serverless or edge application that benefits from connection pooling.
- You need horizontal sharding without managing Vitess directly.
Prerequisites
- A PlanetScale account (free tier available).
- The
pscaleCLI installed locally. - Node.js 18+ if using Prisma or other ORM integrations.
Install the pscale CLI
# macOS
brew install planetscale/tap/pscale
# Linux (deb)
curl -fsSL https://github.com/planetscale/cli/releases/latest/download/pscale_linux_amd64.deb -o pscale.deb
sudo dpkg -i pscale.deb
# Verify installation
pscale version
# Authenticate
pscale auth login
Create and Manage Databases
# Create a new database
pscale database create my-app --region us-east
# List databases
pscale database list
# Show database info
pscale database show my-app
# Delete a database (destructive)
pscale database delete my-app
Branching Workflow
PlanetScale branches work like Git branches for your database schema. The main branch is the production branch by default.
# Create a development branch from main
pscale branch create my-app add-users-table
# List all branches
pscale branch list my-app
# Open a shell on the branch to apply schema changes
pscale shell my-app add-users-table
Apply Schema Changes on a Branch
-- Inside the pscale shell on the development branch
CREATE TABLE users (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY idx_users_email (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE orders (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT NOT NULL,
total DECIMAL(10,2) NOT NULL DEFAULT 0.00,
status ENUM('pending','paid','shipped','cancelled') DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
KEY idx_orders_user_id (user_id),
KEY idx_orders_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
PlanetScale does not enforce foreign keys at the database level. Use application-level constraints or Vitess-level routing rules instead.
Deploy Requests
Deploy requests are the pull-request equivalent for database schemas. They show a diff, run linting, and merge non-blocking into production.
# Create a deploy request from branch to main
pscale deploy-request create my-app add-users-table
# List open deploy requests
pscale deploy-request list my-app
# Show diff for a deploy request
pscale deploy-request diff my-app 1
# Deploy (merge) the request
pscale deploy-request deploy my-app 1
# Close without deploying
pscale deploy-request close my-app 1
# Delete the branch after successful deploy
pscale branch delete my-app add-users-table
Connection Strings and Proxying
# Create a password (connection credential) for a branch
pscale password create my-app main production-creds
# Output includes host, username, and password for the connection string:
# mysql://USERNAME:PASSWORD@HOST/my-app?sslmode=verify_identity
# Proxy a branch to localhost for local development (no password needed)
pscale connect my-app add-users-table --port 3306
Environment Variable Pattern
# .env (local development using pscale connect)
DATABASE_URL="mysql://root@127.0.0.1:3306/my-app"
# .env.production (using PlanetScale connection string)
DATABASE_URL="mysql://USERNAME:PASSWORD@us-east.connect.psdb.cloud/my-app?sslaccept=strict"
Prisma Integration
// prisma/schema.prisma
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma" // required — PlanetScale does not support foreign keys
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String
orders Order[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Order {
id Int @id @default(autoincrement())
userId Int
total Decimal @db.Decimal(10, 2)
…
常见问题
PlanetScale 中的“分支”是什么?
分支就像数据库的独立副本,用于开发和测试新功能或修改,而不会影响主数据库(即生产环境)。
什么是“Deploy Request”?
它是把某个分支中的修改合并到主分支的请求。它类似于对数据库做的代码审查,会展示具体差异,并让你安全地完成部署。
使用 PlanetScale 需要付费吗?
不需要。它提供免费套餐供你入门。只有当你需要更高级的功能或更大的容量时,才需要付费。
详情
作者的原始描述
Operate MySQL-compatible databases on PlanetScale with branching workflows, safe migrations, and production rollouts.
热度
- GitHub 星标
- 48k
- 排名
- #5452
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。