All skills
planetscale avatar

/vitess

@51f2d4b official

Vitess best practices, query optimization, and connection troubleshooting for PlanetScale Vitess databases. Load when working with Vitess databases, sharding, VSchema configuration, keyspace management, or MySQL scaling issues.

Use this Skill: https://skilld.dev/gh/planetscale/database-skills/vitess

This session only. Nothing lands on disk.

referencesschema-changes.md

≈908 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Schema Changes in Vitess

Vitess provides managed, online schema changes (Online DDL) that are non-blocking, trackable, cancellable, revertible, and failover-safe. This is the recommended approach for all production schema changes.

Reference: https://vitess.io/docs/23.0/user-guides/schema-changes/

DDL strategies

Set via VTGate flag --ddl-strategy, session SET @@ddl_strategy, or vtctldclient --ddl-strategy.

Strategy Description
vitess (recommended) VReplication-based. Non-blocking, revertible, failover-safe.
online Alias for vitess
mysql Managed by Vitess scheduler, DDL executed natively by MySQL. Blocking depends on query.
direct Unmanaged. Direct DDL applied to MySQL. Not trackable.

Strategy flags (append to strategy string):

SET @@ddl_strategy = 'vitess --postpone-completion --allow-concurrent';

Key flags: --postpone-launch (queue but don't start), --postpone-completion (run but don't cut over), --allow-concurrent, --declarative (supply desired CREATE TABLE, Vitess computes diff), --singleton, --prefer-instant-ddl (use MySQL INSTANT DDL when possible).

Executing schema changes

SET @@ddl_strategy = 'vitess';
ALTER TABLE demo MODIFY id BIGINT UNSIGNED;  -- returns migration UUID
vtctldclient ApplySchema --ddl-strategy "vitess" \
  --sql "ALTER TABLE demo MODIFY id BIGINT UNSIGNED" commerce

Online DDL supports: ALTER TABLE (non-blocking via VReplication), CREATE TABLE, DROP TABLE (renamed then garbage-collected after 24h), CREATE/ALTER/DROP VIEW. Unsupported DDL (RENAME, TRUNCATE, OPTIMIZE) runs directly on MySQL.

Migration lifecycle

queued → ready → running → complete
                        ↘ failed
         ↘ cancelled

Monitoring and controlling migrations

SHOW VITESS_MIGRATIONS;                                              -- all migrations
SHOW VITESS_MIGRATIONS LIKE 'bf4598ab_8d55_11eb_815f_f875a4d24e90'; -- specific

Key columns: uuid, migration_status, progress, started_timestamp, completed_timestamp, message.

Control commands:

ALTER VITESS_MIGRATION '<uuid>' CANCEL;    -- cancel pending migration
ALTER VITESS_MIGRATION '<uuid>' RETRY;     -- retry failed migration
ALTER VITESS_MIGRATION '<uuid>' COMPLETE;  -- complete a postponed migration
ALTER VITESS_MIGRATION '<uuid>' LAUNCH;    -- launch a postponed migration
REVERT VITESS_MIGRATION '<uuid>';          -- revert last completed migration on table

Declarative migrations

Supply desired CREATE TABLE; Vitess computes the ALTER:

SET @@ddl_strategy = 'vitess --declarative';
CREATE TABLE demo (id BIGINT UNSIGNED NOT NULL, status VARCHAR(32), PRIMARY KEY (id));

Throttling and failover

  • The tablet throttler auto-slows migrations when replication lag is high. Enable: vtctldclient UpdateThrottlerConfig --enable <keyspace>
  • VReplication-based migrations auto-resume after planned/emergency reparenting (new primary must be available within 10 min)

Best practices

  1. Always use vitess strategy for production migrations
  2. Use --postpone-completion for critical migrations to control cut-over timing
  3. Monitor with SHOW VITESS_MIGRATIONS before and after
  4. Enable the tablet throttler to prevent replication lag
  5. Use declarative migrations for desired-state schema management
  6. Avoid direct DDL in production (blocks writes and replication)

Source: SKILL.md on GitHub

1 warning17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill provides comprehensive documentation and best practices for Vitess and PlanetScale databases. It consists entirely of informational markdown files without executable scripts, dependencies, or network operations outside of referencing official vendor resources.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer6mo

    5/6 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 51f2d4b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated 7 months ago
Other metadata
metadata
{
  "author": "planetscale",
  "version": "1.0.0",
  "organization": "PlanetScale",
  "date": "February 2026"
}
  • Database
  • vitess
  • planetscale
  • mysql
  • sharding
  • vschema
  • connection-pooling
  • schema-migrations

README badge

README badge for planetscale/database-skills/vitess

Guides query routing, sharding strategy, schema migration, and MySQL compatibility for Vitess databases on PlanetScale. Covers VSchema configuration, keyspace management, cross-shard query performance, and Online DDL workflows.

Generated from the current SKILL.md.

Does Vitess support stored procedures and triggers?
No. Stored procedures, triggers, and events are not supported through VTGate. Application logic must handle these operations.
What should I use for generating IDs on sharded tables?
Use Vitess Sequences (a global counter in an unsharded keyspace) or app-generated IDs like UUIDs or snowflakes to avoid collisions across shards.
Are cross-shard joins supported?
Yes, but they are expensive scatter-gather operations. Filter by the vindex column to force single-shard routing and avoid cross-shard joins when possible.
How do I apply schema changes in production on PlanetScale?
Use PlanetScale deploy requests, which implement non-blocking Online DDL migrations across all shards without disrupting workloads.
Does Vitess support foreign keys?
Foreign keys have limited support in Vitess. Prefer application-level referential integrity checks on sharded keyspaces.

Generated from the current SKILL.md. These answers refresh after source changes.