data-layer-patterns-edho-ferdian

Designs database schemas, ORM setups, caching strategies, and safe migration sequences before code exists.

2|Updated Sep 6, 2026
One-click install
npx skills add https://github.com/edhoferdian/EEF --skill data-layer-patterns-edho-ferdian-edhoferdian
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-layer-patterns-edho-ferdian
Source: https://github.com/edhoferdian/EEF/tree/main/.agents/skills/data-layer-patterns-edho-ferdian
Command: npx skills add https://github.com/edhoferdian/EEF --skill data-layer-patterns-edho-ferdian-edhoferdian

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Designing a data layer without a clear access pattern leads to schemas that need expensive rework, N+1 query traps, unsafe migrations that lock production tables, and caches with no invalidation plan. This Skill provides design-time guidance for Postgres, MySQL/MariaDB, Prisma, Redis, and JPA so the data layer is shaped correctly before any code exists to review. ## Core Features & Use Cases - Schema and ORM design: Postgres and MySQL/MariaDB schema defaults, indexing strategy, Prisma connection pooling and N+1 avoidance, and JPA entity/fetch/transaction design. - Caching and queue strategy: Redis data structure selection, TTL guidance, cache invalidation patterns (TTL, tag-based, write-through), and Redis Streams vs dedicated queue trade-offs. - Safe migration sequencing: Cross-ORM expand-contract pattern, batched backfills, concurrent index creation, and reversibility requirements for zero-downtime schema changes. - Use Case: When asked "design a schema for a marketplace orders feature", the Skill first establishes the access patterns, then produces a schema with correct indexes, a Prisma or JPA setup, and an expand-contract migration plan that a later code review will not flag. ## Quick Start Ask the assistant to design a Postgres schema and Prisma setup for a new feature, including a safe migration strategy and Redis caching plan.

Frequently Asked Questions about data-layer-patterns-edho-ferdian

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a database schema for a new feature?

Start by stating the access pattern: point lookups vs range scans, read-heavy vs write-heavy, and expected row counts. Then choose primary key strategy, indexes on foreign keys and filter columns, and decide normalized vs denormalized based on measured join cost.

What is the expand-contract migration pattern?

Expand-contract is a three-phase zero-downtime migration: add the new column while writing to both, backfill data and switch reads to the new column, then drop the old column only after the new one is proven in production. Each phase is a separate deploy so you can stop and verify.

Should I use Redis Streams or a dedicated queue like RabbitMQ?

Redis Streams fits when you already run Redis, have modest volume, and at-least-once delivery via consumer groups is enough. Choose a dedicated queue when you need long-term durability, dead-letter queues, cross-region delivery, or exactly-once semantics.

Does this skill review existing SQL or migrations?

No, it is strictly design-time guidance for systems that do not exist yet. Reviewing existing SQL, schemas, or migrations belongs to the code review skill's database lens, which checks queries with EXPLAIN ANALYZE and audit criteria.

How do I avoid N+1 queries with Prisma?

Load relations with include or select in a single findMany call instead of querying inside a loop. Note that include can still generate N+1 on older Prisma versions or explode result sets on large 1:N relations, so benchmark both shapes for hot paths.

When should I not add a NOT NULL constraint directly?

Never add NOT NULL without a default to an existing populated table, since it forces a full table rewrite under lock. Add the column nullable or with a default, backfill the data, then add the constraint as a separate migration.