Command-line Interface

Complete reference for the Xata CLI

The Xata CLI is a powerful tool for managing your Xata databases, projects, and organizations from the command line. It provides commands for authentication, project management, database operations, and more.

Installation

# Install using the official install script
curl -fsSL https://xata.io/install.sh | bash

Note: The CLI binary will be installed to ~/.config/xata/bin/. Make sure this directory is in your PATH.

Installation (Windows)

# Install using npm
powershell -c "irm https://xata.io/install.ps1 | iex"

Note: xata clone currently doesn't work with the native Windows installation. We currently recommend using WSL with the Linux binaries if you need the clone functionality on Windows. Track progress here.

Basic Usage

xata [command] [subcommand] [options]

Available Commands

Authentication

Organization Management

Project Management

Branch Management

API Key Management

Schema Migrations

  • roll baseline - Create a baseline migration for an existing database schema
  • roll complete - Complete an ongoing migration
  • roll init - Initialize pgroll in the target database
  • roll latest - Print the name of the latest schema version or migration
  • roll migrate - Apply outstanding migrations from a directory to a database
  • roll update - Update outdated migrations in a directory
  • roll pull - Pull migration history from the target database and write it to disk
  • roll rollback - Roll back an ongoing migration
  • roll start - Start a migration
  • roll status - Show pgroll status
  • roll convert - Convert SQL statements to a pgroll migration

Database Synchronization

  • clone start - Clone a PostgreSQL database with anonymization
  • clone config - Configure transforms for the clone command

Utility Commands

Global Flags

  • -h, --help - Print help information and exit
  • -v, --version - Print version information and exit
  • --json - Output in JSON format (where applicable)