OpenSky-commerce / Documentation

Database Setup

Open Sky Commerce uses PostgreSQL as its database, accessed through Prisma ORM. The schema is fully defined in prisma/schema.prisma and managed through Prisma migrations.

1. Create a PostgreSQL Database

You can use a local PostgreSQL instance, a managed database (DigitalOcean Managed Databases, Supabase, Neon, Railway), or any PostgreSQL-compatible service.

# Example: create a local database
createdb openskycommerce

2. Set the Connection String

Add your connection string to .env:

DATABASE_URL="postgresql://username:password@localhost:5432/openskycommerce"

For a managed database with SSL:

DATABASE_URL="postgresql://username:password@host:25060/openskycommerce?sslmode=require"

3. Run Migrations

npx prisma migrate dev --name init

This applies all migrations in prisma/migrations/ and creates the full schema in your database.

4. Generate the Prisma Client

npx prisma generate

This is also run automatically as part of npm run build.

5. Seed Demo Data (Optional)

npm run import-demo-data

This script reads JSON files from seed-data/ and populates the database with sample products, categories, blog posts, users, and settings — useful for evaluating the platform before entering your own data.

Prisma Studio

You can browse and edit your database records directly using Prisma Studio:

npx prisma studio

Key Models

  • Product / ProductVariant — product catalog with variants
  • Category — hierarchical product categories
  • Order — customer orders with line items
  • User — customer and admin accounts
  • PaymentSettings — singleton row holding all payment processor keys
  • SeoSetting — site-wide SEO and homepage variant configuration
  • BusinessInfo — company name, address, phone, email
  • Post / PostAuthor / PostCategory — blog system
  • HeroBanner / HeroSlider — homepage hero configuration
  • Coupon — discount codes
  • Review — product reviews