package com.example.myapplication.database.room.model.rent

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.PrimaryKey
import com.example.myapplication.database.room.model.user.User

@Entity(
    tableName = "rents", foreignKeys = [
        ForeignKey(
            entity = User::class,
            parentColumns = ["uid"],
            childColumns = ["user_id"],
            onDelete = ForeignKey.RESTRICT,
            onUpdate = ForeignKey.RESTRICT
        )
    ]
)
data class Rent(
    @PrimaryKey(autoGenerate = true)
    val uid: Int,
    @ColumnInfo(name = "user_id", index = true)
    val userId: Int?,
) {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false
        other as Rent
        if (uid != other.uid) return false
        return true
    }

    override fun hashCode(): Int {
        return uid
    }
}

