Coverage Summary for Class: PendingMutationEntity (com.georgeci.moneysurfer.sync.db.entity)

Class Method, % Branch, % Line, % Instruction, %
PendingMutationEntity 100% (1/1) 100% (10/10) 100% (47/47)
PendingMutationEntity$Companion
Total 100% (1/1) 100% (10/10) 100% (47/47)


 package com.georgeci.moneysurfer.sync.db.entity
 
 import androidx.room.Entity
 import androidx.room.Index
 import androidx.room.PrimaryKey
 
 /**
  * Outbox row — one queued local mutation awaiting push.
  *
  * No FK constraints intentionally: the outbox is an independent ledger that
  * must outlive the row it references (e.g. for DELETE operations the entity
  * is already gone from its primary table).
  *
  * Schema mirrors `sync.md §4.3`.
  */
 @Entity(
     tableName = "pending_mutations",
     // (status, createdAt) as one composite: the drain query is
     // `WHERE status = 'PENDING' ... ORDER BY createdAt ASC LIMIT n`, so the index
     // serves both the filter and the ordering, replacing the two single-column ones.
     indices = [
         Index(value = ["status", "createdAt"]),
         Index("workspaceId"),
     ],
 )
 data class PendingMutationEntity(
     @PrimaryKey val id: String,
     val entityType: String,
     val entityId: String,
     val operation: String,
     val workspaceId: String?,
     val createdAt: Long,
     val attempts: Int,
     val status: String,
     val lastError: String?,
 ) {
     companion object {
         const val STATUS_PENDING: String = "PENDING"
         const val STATUS_IN_FLIGHT: String = "IN_FLIGHT"
         const val STATUS_FAILED: String = "FAILED"
     }
 }