package com.fabledsword.minstrel.cache.db.entities

import androidx.room.Entity
import androidx.room.PrimaryKey
import kotlinx.datetime.Instant

/**
 * Single-row table that tracks where the SyncController left off.
 *
 * Mirrors the Flutter Drift `sync_metadata` table. There is only ever
 * one row at `id = 0`; the SyncController upserts on every successful
 * `/api/sync` call.
 *
 * Pulled into Task 4.1 to give Room a compileable @Database (it needs
 * at least one entity); the SyncController itself lands in Phase 12.4.
 */
@Entity(tableName = "sync_metadata")
data class SyncMetadataEntity(
    @PrimaryKey val id: Int = 0,
    /** Server-issued cursor used as `cursor` query param on the next sync. */
    val cursor: Long = 0,
    /** Wall-clock time of the last successful sync — diagnostic only. */
    val lastSyncAt: Instant? = null,
)
