Skip to main content

Quick Start

This guide will walk you through setting up PostKit and running your first database migration.

1. Initialize a Project

# Create a new directory
mkdir my-app && cd my-app

# Initialize with PostKit CLI
postkit init

This creates:

  • postkit.config.json - Your configuration file
  • db/schema/ - Your schema files directory
  • .postkit/ - Runtime files (gitignored)

2. Configure Remotes

Add your remote databases:

# Add development remote (set as default)
postkit db remote add dev "postgres://user:pass@dev-host:5432/myapp" --default

# Add staging remote
postkit db remote add staging "postgres://user:pass@staging-host:5432/myapp"

3. Start a Migration Session

Clone a remote database to your local machine:

postkit db start

This:

  1. Clones the remote database to local
  2. Creates a session to track your changes
  3. Prepares for schema modifications

4. Make Schema Changes

Edit files in db/schema/:

-- db/schema/tables/users.sql
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email TEXT NOT NULL UNIQUE,
created_at TIMESTAMPTZ DEFAULT NOW()
);

5. Preview Changes

See what will change:

postkit db plan

6. Apply Changes Locally

Test your changes on the local clone:

postkit db apply

7. Commit for Deployment

postkit db commit

This creates a migration file ready for deployment.

8. Deploy to Remote

postkit db deploy --remote staging

PostKit performs a dry-run first to verify the migration works, then deploys to your remote database.

Common Commands

CommandDescription
postkit db startStart a migration session
postkit db planPreview schema changes
postkit db applyApply changes to local DB
postkit db commitCommit migrations for deployment
postkit db deployDeploy to remote database
postkit db statusShow session state
postkit db abortCancel session and clean up

Next Steps