CLI Referenceaerostack db

aerostack db

Manage D1 and Neon Postgres databases — create databases, run migrations, and pull schemas.

Migrations (D1)

Create a migration

aerostack db migrate new <name>

Creates a timestamped SQL migration file in your migrations/ directory.

aerostack db migrate new add_users_table
# Creates: migrations/0001_add_users_table.sql

Apply migrations

# Apply locally (default)
aerostack db migrate apply
 
# Apply to remote staging
aerostack db migrate apply --remote staging
 
# Apply to remote production
aerostack db migrate apply --remote production

Check pending migrations

aerostack db migrate apply --dry-run

Neon Postgres

Create a Neon database

aerostack db neon create <name>

Creates a new Neon Postgres database and adds it to your aerostack.toml.

aerostack db neon create my-postgres-db

Postgres migrations

# Create a Postgres migration
aerostack db migrate new add_users_table --postgres
 
# Apply Postgres migrations
aerostack db migrate apply --postgres
aerostack db migrate apply --postgres --remote production

Pull schema & generate types

aerostack db pull

Alias for aerostack generate types. Introspects your database and generates TypeScript interfaces. See generate types for details.


Typical database workflow

# 1. Create a new migration
aerostack db migrate new add_products_table
 
# 2. Edit the SQL
# vim migrations/0001_add_products_table.sql
 
# 3. Apply locally and test
aerostack db migrate apply
 
# 4. Generate TypeScript types
aerostack generate types
 
# 5. When ready, apply to staging
aerostack db migrate apply --remote staging
⚠️

Always apply migrations to staging before production. Migrations cannot be rolled back automatically — plan your schema changes carefully.