ShipNext

Database

Configure SQLite or PostgreSQL, run Drizzle commands, and switch database schemas.

ShipNext supports SQLite and PostgreSQL. SQLite is the default local setup; PostgreSQL is recommended for many production deployments.

PostgreSQL

PostgreSQL only requires a DATABASE_URL:

DATABASE_URL=postgresql://user:password@host:port/database

Many hosted providers include a free tier that is enough for small personal products.

Neon has a strong developer experience and works well for small projects.

  1. Open Neon and create an account.
  2. Create a project, choose the PostgreSQL version and region.
  3. Click Connection string.
  4. Copy the connection string into DATABASE_URL.
Neon Connection String

Supabase provides PostgreSQL plus auth and storage features.

  1. Open Supabase and create an account.
  2. Create a project, choose a password and region.
  3. Click Connect.
  4. Choose Direct or Transaction pooler.
  5. Copy the connection string into DATABASE_URL.
postgresql://postgres.yprscmdqlicgpgcbcizu:[YOUR-PASSWORD]@aws-1-ap-northeast-1.pooler.supabase.com:6543/postgres

Replace [YOUR-PASSWORD] with the database password.

Supabase Connection String

Docker is useful for local PostgreSQL validation.

docker run --name shipnext-pg -e POSTGRES_PASSWORD=yourpassword -d -p 5432:5432 postgres

Then set:

DATABASE_URL="postgres://postgres:yourpassword@localhost:5432/postgres"

You can also install PostgreSQL locally. Follow the official installation guide, create a user/password, then set:

DATABASE_URL="postgres://postgres:yourpassword@localhost:5432/postgres"

SQLite

SQLite is the default local setup.

Initialize the local database:

pnpm db:push

This creates app.db in the project root.

Cloudflare D1 is a managed SQLite database. Create a D1 database in the Cloudflare dashboard, create an API token with D1 edit permissions, then connect it according to your deployment needs. The original template keeps this as a follow-up integration path.

Turso is a managed SQLite-compatible database.

  1. Open Turso and create an account.
  2. Create a database and choose a location.
  3. Add the connection values required by your Turso setup.
Create Turso Database

Database commands

Push the current schema:

pnpm db:push

Generate migrations:

pnpm db:generate

Run migrations:

pnpm db:migrate

Open Drizzle Studio:

pnpm db:studio

It opens at https://local.drizzle.studio.

Switch database type

ShipNext includes schema files for both PostgreSQL and SQLite. Adjust the exports and client used by your app.

Schema export

export * from "./schema/pg/auth.schema";
export * from "./schema/pg/payment.schema";
export * from "./schema/pg/storage.schema";

Database client

export { db } from "./client/pg";

Drizzle config

import config from "./drizzle.pg.config";

Better Auth adapter

export const auth = betterAuth({
  appName: "ShipNext",
  database: drizzleAdapter(db, {
    provider: "pg",
    schema: {
      user: schema.user,
      session: schema.session,
      account: schema.account,
      verification: schema.verification,
    },
  }),
});

Schema export

export * from "./schema/sqlite/auth.schema";
export * from "./schema/sqlite/payment.schema";
export * from "./schema/sqlite/storage.schema";

Database client

export { db } from "./client/sqlite";

Drizzle config

import config from "./drizzle.sqlite.config";

Better Auth adapter

export const auth = betterAuth({
  appName: "ShipNext",
  database: drizzleAdapter(db, {
    provider: "sqlite",
    schema: {
      user: schema.user,
      session: schema.session,
      account: schema.account,
      verification: schema.verification,
    },
  }),
});

Add a schema

For a new business table, create a schema file such as business.schema.ts and export it from the central schema entry:

export * from "./schema/pg/business.schema";

Use the existing auth, payment, and storage schemas as references.

On this page