package com.syncflow.data.db.entities

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import java.time.Instant

@Entity(
    tableName = "sync_file_states",
    primaryKeys = ["syncPairId", "relativePath"],
    foreignKeys = [ForeignKey(
        entity = SyncPairEntity::class,
        parentColumns = ["id"],
        childColumns = ["syncPairId"],
        onDelete = ForeignKey.CASCADE,
    )],
    indices = [Index("syncPairId")],
)
data class SyncFileStateEntity(
    val syncPairId: Long,
    val relativePath: String,
    val localModifiedAt: Instant?,
    val localSizeBytes: Long,
    val localHash: String?,
    val remoteModifiedAt: Instant?,
    val remoteSizeBytes: Long,
    val remoteEtag: String?,
    val lastSyncedAt: Instant,
    val syncedHash: String?,
)
