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 openskycommerce2. 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 initThis applies all migrations in prisma/migrations/ and creates the full schema in your database.
4. Generate the Prisma Client
npx prisma generateThis is also run automatically as part of npm run build.
5. Seed Demo Data (Optional)
npm run import-demo-dataThis 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 studioKey Models
Product/ProductVariant— product catalog with variants and aproductTypeenum (PHYSICAL, DIGITAL, SUBSCRIPTION_PHYSICAL, SUBSCRIPTION_DIGITAL, SERVICE_APPOINTMENT)SubscriptionPlan— billing interval and price attached to subscription productsCategory— hierarchical product categoriesOrder— customer orders with line items; subscription orders include lifecycle fields (status, billing period, stored payment IDs)User— customer and admin accountsPaymentSettings— singleton row holding all payment processor keys (stored encrypted)ShippingSettings— singleton row holding active shipping provider and credentials (stored encrypted)SeoSetting— site-wide SEO and homepage variant configurationBusinessInfo— company name, address, phone, email (used as shipping origin)Post/PostAuthor/PostCategory— blog systemHeroBanner/HeroSlider— homepage hero configurationCoupon— discount codesReview— product reviews
Connection Pooling Note
On hosted platforms like DigitalOcean App Platform, Prisma's default connection pool can exhaust a managed database's connection limit (typically 25) when multiple app instances run. Append connection_limit=5 to your DATABASE_URL to cap the pool per instance:
DATABASE_URL="postgresql://...?sslmode=require&connection_limit=5"