package space.nstart.pcp.pcp_satellites_service.entity

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.FetchType
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.Table
import jakarta.persistence.UniqueConstraint
import jakarta.persistence.Index

@Entity
@Table(
    name = "satellite_mode_cell",
    uniqueConstraints = [
        UniqueConstraint(
            name = "uq_satellite_mode_cell_mode_cell",
            columnNames = ["mode_id", "cell_num"]
        )
    ],
    indexes = [
        Index(name = "idx_satellite_mode_cell_mode_id", columnList = "mode_id"),
        Index(name = "idx_satellite_mode_cell_cell_num", columnList = "cell_num")
    ]
)
class SatelliteModeCellEntity(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null,

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "mode_id", nullable = false)
    var mode: SatelliteModeEntity? = null,

    @Column(name = "cell_num", nullable = false)
    var cellNum: Long = 0
)
