- Home
- Skills
- Rubenpenap
- Epic Stack Agent Skills
- Epic Database
epic-database_skill
3
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill rubenpenap/epic-stack-agent-skills --skill epic-database- SKILL.md15.6 KB
Overview
This skill is a focused guide for using Prisma with SQLite and LiteFS in the Epic Stack. It explains schema design, migrations, multi-region considerations, and pragmatic query optimization. The goal is practical, production-ready advice for building fast, maintainable apps with minimal complexity.
How this skill works
The skill walks through Prisma schema patterns (models, relations, indexes), migration workflows, and seed scripts. It covers SQLite-specific operation with LiteFS for multi-region setups, including how to detect the primary instance for writes and how reads behave on replicas. It also shows pragmatic query examples, transactions, and logging to measure and optimize performance.
When to use it
- Designing or refactoring a Prisma schema for an Epic Stack app
- Creating and applying migrations locally and in production
- Running a multi-region SQLite deployment with LiteFS where primary/replica behavior matters
- Writing seed scripts, transactional flows, or complex queries with pagination
- Diagnosing slow queries and deciding where to add indexes
Best practices
- Fetch only the fields you need using select; avoid over-fetching entire models
- Prefer simple, readable queries and optimize only after measuring real bottlenecks
- Index foreign keys and fields used frequently in where/orderBy; add composite indexes for measured needs
- Follow a widen-then-narrow migration strategy for zero-downtime schema changes
- Use transactions for multi-step, related writes and ensure writes run on the LiteFS primary
Example use cases
- Create a User and related Note models with proper indexes and cascade delete
- Implement paginated post listing with selective relation includes and total count
- Run seed scripts to populate roles, permissions, and example users before first deploy
- Detect LiteFS primary before performing write operations and redirect reads to replicas as needed
- Log slow Prisma queries and add indexes based on observed durations
FAQ
Check currentIsPrimary via your LiteFS helper and call ensurePrimary before performing writes; replicas are read-only.
When should I add an index?
Add indexes when a query is measurably slow and the indexed fields are used frequently in where or orderBy clauses; avoid premature indexing.