What problem does it solve?
This Skill solves the inconsistency and fragility of database code by standardizing audit fields, soft-deletes, dual human/technical IDs, pagination, deletion eligibility, and the migration workflow so your Next.js/Drizzle projects behave predictably in production.
Core Features & Use Cases
- Enforces mandatory audit fields: Adds
createdAt/createdBy/modifiedAt/modifiedBy via auditFields and documents how to populate them using the kit’s injected userId from server action wrappers.
- Implements soft delete conventions: Adds
deletedAt/deletedBy with softDeleteFields and guarantees reads filter out deleted rows via notDeleted().
- Standardizes dual-ID human identifiers: Provides
generateHumanId, atomic sequence-based getNextHumanId, gap-resilient getNextHumanIdSeq, and race-safe withHumanIdRetry() including the required SAVEPOINT behavior when called inside a parent transaction.
- Provides safe pagination primitives: Uses
parsePaginationParams, buildPaginationSQL, and createCachedCount with revalidation tagging to prevent stale totals.
- Adds hard-delete eligibility checks: Uses
canHardDeleteUser to prevent permanent deletion when downstream references exist.
- Gives repeatable migration and DB inspection workflow: Establishes
db:generate → review SQL → db:migrate, and read-only inspection via pnpm db:query.
Quick Start
Use the sk-db helpers when creating new Drizzle schema files and mutations to ensure every table includes auditFields, applies softDeleteFields where appropriate, and uses the kit’s pagination, human-id, and migration conventions.