shadpanel db
Database management commands powered by Prisma ORM.
Overview
ShadPanel includes powerful database management through Prisma. The shadpanel db commands help you:
- Initialize database configuration
 - Generate Prisma schemas from templates
 - Run migrations and sync your database
 - Open Prisma Studio to browse data
 - Seed and reset your database
 
Commands
db init
Initialize database configuration interactively.
shadpanel db initWhat it does:
- Prompts for database type (MySQL, PostgreSQL, SQLite, MongoDB)
 - Creates 
.envfile with database URL template - Creates 
prisma/schema.prisma.template - Optionally installs Prisma packages
 
Example:
$ shadpanel db init
 
🗄️  Let's set up your database!
 
? Select your database provider ›
  ❯ PostgreSQL
    MySQL
    SQLite
    MongoDB
 
? Install Prisma packages? › Yes
? Which package manager? › pnpm
 
✓ Environment configuration created (.env)
✓ Prisma files created
✓ Prisma packages installed
 
✅ Database setup complete!Generated files:
.env- Database connection URLprisma/schema.prisma.template- Schema template
db generate
Generate Prisma Client from schema.
shadpanel db generateWhat it does:
- Generates Prisma Client (TypeScript types + database client) from your existing 
prisma/schema.prisma. 
Note: The
shadpanel db generate-schemacommand was removed — define your schema manually inprisma/schema.prisma(or use yourprisma/schema.prisma.templateworkflow) before running this command.
Example:
$ shadpanel db generate
 
✓ Generating Prisma schema from template...
✓ Generating Prisma Client...
 
✅ Database setup complete!Use Prisma Client:
import { PrismaClient } from '@prisma/client'
 
const prisma = new PrismaClient()
 
// Now you can use prisma.user.findMany(), etc.db migrate
Run database migrations.
shadpanel db migrate [name] [options]Arguments:
[name]- Optional migration name (e.g., “add_users_table”)
Options:
--regenerate- Regenerate schema from template before migrating
Examples:
# Create migration from current schema
shadpanel db migrate add_users
 
# Regenerate from template, then migrate
shadpanel db migrate add_users --regenerate
 
# Without name (prompts for name)
shadpanel db migrateWhat it does:
- Optionally regenerates schema from template
 - Creates migration files in 
prisma/migrations/ - Applies migrations to database
 - Generates Prisma Client
 
Status
shadpanel db migrate statusUp-to-date:
✔ Database is up to date! (N migrations applied)With pending migrations:
✔ Already on database: 4
✖ Pending: 1
Pending migrations:
  → 20251102224716_add_test_fielddb push
Push schema to database without migrations.
shadpanel db push [options]Options:
--regenerate- Regenerate schema from template before pushing
Examples:
# Push current schema
shadpanel db push
 
# Regenerate from template, then push
shadpanel db push --regenerateWhen to use:
- Prototyping and development
 - Don’t need migration history
 - Quick schema changes
 
When NOT to use:
- Production environments
 - Need migration history
 - Working in a team
 
db pull
Introspect existing database and update schema.
shadpanel db pull [options]Options:
--force- Overwrite existing schema
Examples:
# Pull schema from database
shadpanel db pull
 
# Force overwrite existing schema
shadpanel db pull --forceUse case:
- Connect to existing database
 - Reverse-engineer schema
 - Sync with database changes made outside Prisma
 
db studio
Open Prisma Studio to browse and edit data.
shadpanel db studio [options]Options:
-p, --port <port>- Port to run on (default: 5555)-b, --browser <browser>- Browser to open
Examples:
# Open on default port (5555)
shadpanel db studio
 
# Custom port
shadpanel db studio --port 3333
 
# Specific browser
shadpanel db studio --browser firefoxWhat it does:
- Starts Prisma Studio web interface
 - Opens browser automatically
 - Browse, create, edit, delete records
 - Visual database management
 
Press Ctrl+C to stop
db seed
Seed database with initial data.
shadpanel db seedRequirements:
Add seed script to package.json:
{
  "prisma": {
    "seed": "tsx prisma/seed.ts"
  }
}Example seed file (prisma/seed.ts):
import { PrismaClient } from '@prisma/client'
 
const prisma = new PrismaClient()
 
async function main() {
  await prisma.user.createMany({
    data: [
      { email: 'alice@example.com', name: 'Alice' },
      { email: 'bob@example.com', name: 'Bob' },
    ],
  })
}
 
main()
  .then(async () => {
    await prisma.$disconnect()
  })
  .catch(async (e) => {
    console.error(e)
    await prisma.$disconnect()
    process.exit(1)
  })db reset
Reset database (WARNING: deletes all data).
shadpanel db reset [options]Options:
--force- Skip confirmation prompt
Examples:
# Reset with confirmation
shadpanel db reset
 
# Reset without confirmation
shadpanel db reset --forceWhat it does:
- Drops database
 - Creates fresh database
 - Runs all migrations
 - Runs seed script (if configured)
 
⚠️ WARNING: This deletes all data permanently!
Workflows
NOTE: The
shadpanel db generate-schemacommand has been removed. Create or editprisma/schema.prismamanually. To apply changes and update the Prisma client, either runshadpanel db migrate [name](to create migrations) orshadpanel db push(for prototyping) and then runshadpanel db generateto regenerate the Prisma Client.
Workflow 1: Template-Based (Recommended)
For reusable schemas and team collaboration:
- 
Initialize database:
shadpanel db init - 
Edit template: Edit
prisma/schema.prisma.template:datasource db { provider = "{{DATABASE_DRIVER}}" url = "{{DATABASE_URL}}" } generator client { provider = "prisma-client-js" } model User { id Int @id @default(autoincrement()) email String @unique name String? posts Post[] createdAt DateTime @default(now()) } model Post { id Int @id @default(autoincrement()) title String content String? authorId Int author User @relation(fields: [authorId], references: [id]) createdAt DateTime @default(now()) } - 
Generate and migrate:
shadpanel db migrate init --regenerate - 
Make changes:
- Edit template
 - Run 
shadpanel db migrate update --regenerate 
 
Benefits:
- ✅ Version controlled template
 - ✅ Reusable across environments
 - ✅ Team consistency
 
Workflow 2: Direct Editing
For one-time changes and simple projects:
- Initialize database:
 
shadpanel db init- Create or edit schema manually:
Edit (or create) 
prisma/schema.prismadirectly, for example: 
model User {
  id    Int    @id @default(autoincrement())
  email String @unique
  name  String?
}- Apply changes and generate client:
 
- To create migrations and apply them:
shadpanel db migrate [name] - For quick prototyping (no migration history):
shadpanel db push 
After either command, regenerate the Prisma Client:
shadpanel db generateBenefits:
- ✅ Simple and direct
 - ✅ No template management required
 - ✅ Quick changes
 
Workflow 3: Prototyping
For rapid development without migrations:
- Initialize database:
 
shadpanel db init- 
Edit schema directly: Edit
prisma/schema.prismaas needed. - 
Push to database:
 
shadpanel db push- Regenerate Prisma Client:
 
shadpanel db generate- Repeat:
 
- Make schema changes
 - Run 
shadpanel db pushandshadpanel db generateagain 
Benefits:
- ✅ Fast iteration
 - ✅ No migration files
 - ❌ No migration history
 
Database Configuration
Supported Databases
PostgreSQL
# .env
DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}MySQL
# .env
DATABASE_URL="mysql://user:password@localhost:3306/mydb"datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}SQLite
# .env
DATABASE_URL="file:./dev.db"datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}MongoDB
# .env
DATABASE_URL="mongodb+srv://user:password@cluster.mongodb.net/mydb"datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}Common Issues
Connection Errors
Problem: Cannot connect to database
Solutions:
# Check database is running
# For PostgreSQL
pg_isready
 
# For MySQL
mysqladmin ping
 
# Check credentials in .env
cat .env | grep DATABASE_URLPermission Errors
Problem: User doesn’t have permissions
Solutions:
-- PostgreSQL
GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
 
-- MySQL
GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;Migration Conflicts
Problem: Migration conflicts or schema drift
Solutions:
# Reset database (development only)
shadpanel db reset --force
 
# Or manually resolve
prisma migrate resolve --rolled-back "migration_name"Schema Template Not Found
Problem: schema.prisma.template doesn’t exist
Solution:
# Re-initialize database
shadpanel db initBest Practices
1. Use Templates for Teams
Always use schema.prisma.template for team projects:
- ✅ Version controlled
 - ✅ Consistent across environments
 - ✅ Easy to regenerate
 
2. Run Migrations in Production
Use migrations (db migrate) instead of push:
- ✅ Migration history
 - ✅ Rollback capability
 - ✅ Safe deployments
 
3. Seed Development Data
Create seed scripts for consistent development:
// prisma/seed.ts
export async function seed() {
  // Create test users, posts, etc.
}4. Back Up Before Reset
Always backup before db reset:
# PostgreSQL
pg_dump mydb > backup.sql
 
# MySQL
mysqldump mydb > backup.sqlSee Also
- Database Integration - Prisma integration guide
 - Project Structure - Understanding the prisma folder
 - Prisma Documentation - Official Prisma docs