0%
balqalam Logo
balqalam
FeaturesCommunityPricingDocumentation
Login
  • Introduction
  • Pitch
  • Hogwarts
  • Live Demo
  • MVP
  • Roadmap
  • Launch Sprint
  • PRD
  • Get Started
  • Localhost
  • Architecture
  • Structure
  • Pattern
  • Page
  • Layout
  • Content
  • Types
  • Config
  • Actions
  • Queries
  • Authorization
  • Validation
  • Form
  • Table
  • Detail
  • Card
  • Util
  • Hooks
  • List Params
  • Views
  • README.md
  • ISSUE.md
  • Technology Stack
  • Database
  • File
  • CDN Assets
  • Entry Points
  • Dashboard
  • Authentication
  • Credentials
  • OAuth
  • Flow Diagrams
  • Multi-Tenancy
  • Offline
  • Onboarding
  • Onboarding Videos
  • Add Values
  • Admission
  • Application
  • Attendance
  • Compliance
  • Profile
  • Exams
  • Exam Wizard
  • Timetable
  • Classrooms
  • Notifications
  • Conference
  • LMS (Lumos)
Finance
  • Finance
  • Fee Management
  • Invoice
  • Wallet
  • Salary
  • Payroll
  • Timesheet
  • Expenses
  • Budget
  • Receipt
  • Accounts
  • Banking
  • Reports
  • Dashboard
  • Permissions
  • Messages
  • Integration Flow
  • Provision
  • AI Document Processing
  • Document Intelligence
  • Internationalization
  • Translation
  • Translation Guide
  • Icons
  • Docs Factory
  • Inspiration
  • Listings
  • Teachers
  • Students
  • Catalog
  • Library
  • Contributing
  • Code of conduct
  • GitHub Workflow
  • Database Seeds
  • Database Safety
  • Test Accounts
  • Playwright
  • Prettier
  • Block Rebound
Sales & GTM
  • Marketing Brief
  • Sales
  • Go-to-market
  • Marketing
  • Admission — Feature Spotlight
  • Pilot Program
  • Leads
  • Proposal
  • Outreach Templates
  • Case Study
  • Competitors
  • Landing-page teardown
  • Competitor FAQ
  • Business model
  • Shared economy
  • Traction
Fundraising & Ecosystem
  • Get Support
  • Investor Deck
  • Data Room
  • Investors
  • Accelerators
  • Incubators
  • Grants
  • Sponsors
  • Partners
  • Competitions & Hackathons
  • Universities & Training Centers

Database Safety

PreviousNext

Layered protection — destructive command blocking, single-module seeds, and Neon branch-before-touch.

Hogwarts is a multi-tenant SaaS — one database serves every school. A stray DROP TABLE, TRUNCATE, or unreviewed migration wipes data for every tenant. Protection is layered.

Active mechanisms

LayerMechanismBlocks
PreToolUse hookGrep on every Bash commandmigrate reset, db execute, accept-data-loss, DROP TABLE, TRUNCATE, DELETE FROM, ALTER TABLE...DROP
Permission deny listHard deny in settings.jsonpnpm db:seed, prisma migrate reset, prisma db push --accept-data-loss, prisma db execute
Pre-commit seed checkScans staged seed filesdeleteMany, .delete(), TRUNCATE, DROP, $executeRaw
ensure-demo.tsIdempotent build scriptSafe to repeat
single.ts global flagSkips school resolution for global seedsFailure when schools table empty

Seed system

Seeds split into global and school-scoped in prisma/seeds/single.ts.

Global (global: true) — populate platform-wide reference data:

SeedDescription
catalogGlobal catalog (subjects, chapters, lessons)
usUS K-12 catalog from the US-curriculum inventory
schoolDemo school + branding

School-scoped — require demo school to exist (students, teachers, classes, attendance, etc.).

pnpm db:seed:single --list    # List all seeds
pnpm db:seed:single catalog   # Global seed (works on empty DB)
pnpm db:seed:single subjects  # School-scoped seed (requires demo)
pnpm db:seed                  # BLOCKED — see below

Why pnpm db:seed is blocked

The full seed runs every module sequentially and takes 45–120 minutes. Blocked because: it's slow and always times out in CI, it re-seeds foundations risking duplicates, and single-module seeding always suffices for development. Run it manually outside Claude Code only if you genuinely need a full reset.

Neon branch-before-touch

Before any schema change or operation that could affect existing data:

  1. Create a Neon branch (Neon MCP create_branch).
  2. Test the operation on the branch.
  3. If successful → apply to main.
  4. If failed → delete the branch — zero damage.
neon branches create --name "test-migration"
prisma migrate dev --create-only
cat prisma/migrations/<timestamp>/migration.sql   # Review SQL
# If safe → apply to main. Else → neon branches delete "test-migration"

Command reference

Safe (always allowed)

CommandPurpose
prisma generateRegenerate Prisma client from schema
prisma db pushSync schema (no --accept-data-loss)
prisma migrate dev --create-onlyGenerate migration SQL for review
pnpm db:seed:single <name>Seed one module
pnpm db:seed:single --listList available seeds

Blocked

CommandWhy
pnpm db:seedSlow, full-DB risk
prisma migrate resetDrops entire database
prisma db push --accept-data-lossDrops tables with data
prisma db executeRaw SQL
DROP TABLE / TRUNCATEDestroys data
DELETE FROMBulk row delete
ALTER TABLE...DROPColumn drops

Ask first

CommandWhen
prisma migrate devCreate + apply migration (review SQL first)
ALTER TABLE...ADD COLUMNAdding columns is safe but confirm schema

Recovery

Schema out of sync — prisma db push. Adds missing tables/columns without dropping data.

Missing tables —

prisma db push
pnpm db:seed:single school
pnpm db:seed:single auth

Need a column — write targeted SQL:

ALTER TABLE "YourTable" ADD COLUMN IF NOT EXISTS "newColumn" TEXT;

Accidental data loss — if a Neon branch existed before the operation, restore from it. Otherwise contact the team to restore from Neon's automatic backups.

See also

  • Accounts
  • Architecture
Database SeedsTest Accounts

On This Page

Active mechanismsSeed systemWhy pnpm db:seed is blockedNeon branch-before-touchCommand referenceSafe (always allowed)BlockedAsk firstRecoverySee also

Built by Databayt ·

Welcome to balqalam.

A great journey is about to begin.