package com.placeholder.sherpai2.data.local.entity

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index

/**
 * Join table linking images to tags.
 *
 * This is NOT optional.
 * Do not inline tag lists on ImageEntity.
 */
@Entity(
    tableName = "image_tags",
    primaryKeys = ["imageId", "tagId"],
    foreignKeys = [
        ForeignKey(
            entity = ImageEntity::class,
            parentColumns = ["imageId"],
            childColumns = ["imageId"],
            onDelete = ForeignKey.CASCADE
        ),
        ForeignKey(
            entity = TagEntity::class,
            parentColumns = ["tagId"],
            childColumns = ["tagId"],
            onDelete = ForeignKey.CASCADE
        )
    ],
    indices = [
        Index("tagId"),
        Index("imageId")
    ]
)
data class ImageTagEntity(

    val imageId: String,
    val tagId: String,

    /**
     * AUTO | MANUAL
     */
    val source: String,

    /**
     * ML confidence (0–1).
     */
    val confidence: Float,

    /**
     * PUBLIC | PRIVATE | HIDDEN
     */
    val visibility: String,

    val createdAt: Long
)
