Prerequisites

  • DigitalOcean Managed Database for PostgreSQL
  • Access to DigitalOcean Console
  • Xata account and project setup
  • Network access to your DigitalOcean database

Install and Configure the Xata CLI

Install the Xata CLI:
curl -fsSL https://xata.io/install.sh | bash
Authenticate with your Xata account:
xata auth login

Network Configuration

Option 1: Public Access (Default)

DigitalOcean Managed Databases are typically accessible from the internet:
  1. No additional configuration needed for public access
  2. SSL is required by default
  3. Connection limits may apply based on your plan

Option 2: Private Network (Premium Plans)

If you’re on a Premium plan with private network:
  1. Enable Private Network:
    • Go to your database cluster → “Settings” → “Networking”
    • Enable “Private Network”
    • Configure VPC peering if needed
  2. Run Migration from DigitalOcean:
    • Use Droplets in the same private network
    • Use App Platform or Functions in the same VPC

Get Connection String

Find Your Connection Details

  1. Go to DigitalOcean Console → Databases
  2. Click on your PostgreSQL cluster
  3. Go to “Settings” → “Connection Details”
  4. Copy the connection string

Connection String Format

DigitalOcean connection strings typically look like this:
postgresql://your_username:your_password@your-db-host:5432/defaultdb?sslmode=require

Initialize Xata Project

Set up your Xata project configuration:
xata init

Configure the Migration

Set up your clone configuration with optional anonymization:
# Set your source URL
export XATA_CLI_SOURCE_POSTGRES_URL="postgresql://your_username:your_password@your-db-host:5432/defaultdb?sslmode=require"

# Configure anonymization rules
xata clone config --source-url $XATA_CLI_SOURCE_POSTGRES_URL --mode prompt

Start the Migration

Begin the data transfer:
# Start the migration
xata clone start --source-url $XATA_CLI_SOURCE_POSTGRES_URL

Monitor Progress

Check the migration status:
xata clone status

Verification

After migration, verify your data:
  1. Connect to Xata Branch:
    psql `xata branch url`
    
  2. Check Data Integrity:
    -- Compare row counts
    SELECT COUNT(*) FROM your_table;
    
    -- Check sample data
    SELECT * FROM your_table LIMIT 10;
    
  3. Test Relationships: Verify foreign key relationships work correctly

Next Steps