package com.syncflow.data.db.entities

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
import com.syncflow.domain.model.ConflictResolution
import java.time.Instant

@Entity(
    tableName = "sync_conflicts",
    foreignKeys = [ForeignKey(
        entity = SyncPairEntity::class,
        parentColumns = ["id"],
        childColumns = ["syncPairId"],
        onDelete = ForeignKey.CASCADE,
    )],
    indices = [Index("syncPairId")],
)
data class SyncConflictEntity(
    @PrimaryKey(autoGenerate = true) val id: Long = 0,
    val syncPairId: Long,
    val relativePath: String,
    val localModifiedAt: Instant,
    val localSizeBytes: Long,
    val remoteModifiedAt: Instant,
    val remoteSizeBytes: Long,
    val resolution: ConflictResolution?,
    val detectedAt: Instant,
)
