room-entity-pattern

Generate Room entity, DAO, mapper, and repository files with migration workflows.

51|6|Updated Mar 10, 2019
One-click install
npx skills add https://github.com/AniTrend/anitrend-v2 --skill room-entity-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: room-entity-pattern
Source: https://github.com/AniTrend/anitrend-v2/tree/main/.agents/skills/room-entity-pattern
Command: npx skills add https://github.com/AniTrend/anitrend-v2 --skill room-entity-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you avoid fragile, inconsistent persistence implementations by providing a repeatable Room entity/DAO/mapper/repository template and a safe migration checklist.

Core Features & Use Cases

  • Four-file pattern: Produces XxxEntity, XxxDao, XxxMapper, and XxxRepository that align domain logic with Room persistence.
  • Surrogate-PK join table rules: Ensures many-to-many and connection tables behave correctly with composite uniqueness and conflict-safe upserts.
  • Migration checklist: Guides schema-impacting changes through versioning, schema export inspection, validation, and on-device smoke testing.

Quick Start

Follow the Room Entity / DAO / Mapper / Repository Pattern by modeling your new persistence table as a nullable surrogate-PK entity (when appropriate) and wiring it through the four-file pattern starting from the existing tag implementation.

Frequently Asked Questions about room-entity-pattern

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

FAQPage Schema
How do I structure Room entities, DAOs, and repositories consistently in Android?

Structure Room entities consistently by applying a four-file pattern: XxxEntity, XxxDao, XxxMapper, and XxxRepository, which aligns domain logic with Room persistence and prevents inconsistent data layer implementations.

What's the best way to handle Room many-to-many join tables with safe upserts?

Handle Room many-to-many join tables by applying surrogate-PK rules with composite unique indices and REPLACE conflict-safe upserts, ensuring connection tables behave correctly without duplicate relation records.

How do I safely perform SQLite schema versioning and migrations in Room?

Safely perform SQLite schema versioning in Room by executing a schema version bump, applying AutoMigration or manual Migration, verifying schema JSON, validating builds, and running on-device migration smoke tests.

When do I need to bump the Room database schema version?

You need to bump the Room database schema version whenever you add or modify Room entities, join tables, or dynamic query filters, triggering the required migration checklist to prevent unsafe schema changes.

Can I use AutoMigration for all Room schema changes?

AutoMigration handles many Room schema changes, but complex modifications may require manual Migration classes; both paths require schema JSON verification, build validation, and on-device migration smoke testing.

Why are my Room repository queries inconsistent with my domain models?

Room repository queries become inconsistent with domain models when missing a standardized mapper layer; implementing the XxxMapper file within the four-file pattern translates persistence entities into domain logic safely.