Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

2.7 KB
Raw Blame

create-db-cli

Use create-db for instant Prisma Postgres provisioning from the terminal.

Priority

CRITICAL

Why It Matters

create-db is the fastest way to get a working Prisma Postgres instance for development, demos, and CI previews. It can also emit machine-readable output and write env variables directly.

Commands

npx create-db@latest
npx create-db@latest create [options]
npx create-db@latest regions

Aliases:

npx create-pg@latest
npx create-postgres@latest

Command discovery (--help)

Always use --help first when integrating CLI commands:

npx create-db@latest --help
npx create-db@latest create --help
npx create-db@latest regions --help

Top-level commands currently exposed:

  • create (default) to provision a database
  • regions to list available regions

create options

Flag Shorthand Description
--region [string] -r Region choice: ap-southeast-1, ap-northeast-1, eu-central-1, eu-west-3, us-east-1, us-west-1
--interactive [boolean] -i Open region selector
--json [boolean] -j Output machine-readable JSON
--env [string] -e Write DATABASE_URL and CLAIM_URL into a target .env

Lifecycle and claim flow

  • Databases are temporary by default.
  • Unclaimed databases are auto-deleted after ~24 hours.
  • Claim the database using the URL shown in command output to keep it permanently.

Programmatic usage (library API)

You can also use create-db programmatically in Node.js/Bun instead of shelling out to the CLI.

Install:

npm install create-db
# or
bun add create-db

Create a database:

import { create, isDatabaseSuccess, isDatabaseError } from "create-db";

const result = await create({
  region: "us-east-1",
  userAgent: "my-app/1.0.0",
});

if (isDatabaseSuccess(result)) {
  console.log(result.connectionString);
  console.log(result.claimUrl);
  console.log(result.deletionDate);
}

if (isDatabaseError(result)) {
  console.error(result.error, result.message);
}

List regions programmatically:

import { regions } from "create-db";

const available = await regions();
console.log(available);

Programmatic create() defaults to us-east-1 if no region is passed.

Common patterns

# quick database
npx create-db@latest

# region-specific database
npx create-db@latest --region eu-central-1

# interactive region selection
npx create-db@latest --interactive

# write env vars for app bootstrap
npx create-db@latest --env .env

# CI-friendly output
npx create-db@latest --json

References