package com.manalejandro.odb2bluetooth.data.database.entities

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey

/**
 * Entity representing a vehicle generation in the database
 */
@Entity(
    tableName = "generations",
    foreignKeys = [
        ForeignKey(
            entity = Model::class,
            parentColumns = ["id"],
            childColumns = ["model_id"],
            onDelete = ForeignKey.CASCADE
        )
    ],
    indices = [Index("model_id")]
)
data class Generation(
    @PrimaryKey(autoGenerate = true)
    val id: Int = 0,
    @ColumnInfo(name = "model_id")
    val modelId: Int,
    val name: String,
    val code: String?,
    @ColumnInfo(name = "start_year")
    val startYear: Int?,
    @ColumnInfo(name = "end_year")
    val endYear: Int?,
    val description: String?
)

