PlanetScale
PlanetScale is a serverless database platform based on MySQL that provides horizontal scaling, branching workflows, and zero-downtime schema changes. Alchemy provides resources to manage PlanetScale databases and branches programmatically.
Official PlanetScale Documentation | PlanetScale API Reference
Resources
Section titled “Resources”- Database - Create and manage PlanetScale databases with configuration options
- Branch - Create and manage database branches for development workflows
- Password - Create and manage database passwords with specific roles and permissions
Example Usage
Section titled “Example Usage”import { Database, Branch, Password } from "alchemy/planetscale";
// Create a databaseconst database = await Database("my-app-db", { name: "my-app-db", organizationId: "my-org", clusterSize: "PS_10", allowDataBranching: true, automaticMigrations: true,});
// Create a development branchconst devBranch = await Branch("feature-123", { name: "feature-123", organizationId: "my-org", databaseName: database.name, parentBranch: "main", isProduction: false,});
// Create a production branch from a backupconst prodBranch = await Branch("production", { name: "production", organizationId: "my-org", databaseName: database.name, parentBranch: "main", isProduction: true, clusterSize: "PS_20", backupId: "backup-123",});
// Create passwords for database accessconst readerPassword = await Password("app-reader", { name: "app-reader", organizationId: "my-org", databaseName: database.name, branchName: "main", role: "reader"});
const writerPassword = await Password("app-writer", { name: "app-writer", organizationId: "my-org", databaseName: database.name, branchName: devBranch.name, role: "writer", ttl: 86400 // 24 hours});