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.Index
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.Table
import jakarta.persistence.UniqueConstraint

@Entity
@Table(
    name = "complex_plan_run_satellite",
    uniqueConstraints = [
        UniqueConstraint(
            name = "uq_complex_plan_run_satellite_run_satellite",
            columnNames = ["run_id", "satellite_id"]
        )
    ],
    indexes = [
        Index(name = "idx_complex_plan_run_satellite_run_id", columnList = "run_id"),
        Index(name = "idx_complex_plan_run_satellite_satellite_id", columnList = "satellite_id")
    ]
)
class ComplexPlanRunSatelliteEntity(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null,

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "run_id", nullable = false)
    var run: ComplexPlanRunEntity? = null,

    @Column(name = "satellite_id", nullable = false)
    var satelliteId: Long = 0
)
