Setup

Connect this project to your Xata account, initialize pgroll and run migrations

xataio 85e3542 1.2 KB Updated

File contents

Setup Xata project

Connect this project to your Xata account and database.

Steps

  1. Authenticate with Xata (if not already logged in):

    xata auth login
    
  2. Initialize the project:

    xata init
    

    Follow the prompts to select your organization, project and branch.

  3. Get the connection string:

    xata branch url
    
  4. Create .env.local with the connection string:

    echo "DATABASE_URL=<paste connection string>" > .env.local
    
  5. Initialize pgroll (one-time setup):

    xata roll init
    
  6. Run all migrations:

    xata roll start migrations/001_create_users.yaml
    xata roll complete
    xata roll start migrations/002_add_role.yaml
    xata roll complete
    xata roll start migrations/003_add_teams.yaml
    xata roll complete
    
  7. Verify the setup:

    psql $(xata branch url) -c "SELECT * FROM users;"
    

Notes

  • The xata init command creates a .xata folder with configuration
  • Connection strings include credentials — never commit .env.local
  • xata roll init only needs to run once per database

xataio/nextjs-claude-code-starter/tree/main/.claude/skills/setup commit 85e354216e

Frequently asked questions

npx skillmds@latest add xataio/setup