using ScadaLink.Commons.Types.Enums;

namespace ScadaLink.Commons.Entities.Deployment;

public class DeploymentRecord
{
    public int Id { get; set; }
    public int InstanceId { get; set; }
    public DeploymentStatus Status { get; set; }
    public string DeploymentId { get; set; }
    public string? RevisionHash { get; set; }
    public string DeployedBy { get; set; }
    public DateTimeOffset DeployedAt { get; set; }
    public DateTimeOffset? CompletedAt { get; set; }
    public string? ErrorMessage { get; set; }

    /// <summary>
    /// WP-4: Optimistic concurrency token for deployment status updates.
    /// </summary>
    public byte[] RowVersion { get; set; } = [];

    public DeploymentRecord(string deploymentId, string deployedBy)
    {
        DeploymentId = deploymentId ?? throw new ArgumentNullException(nameof(deploymentId));
        DeployedBy = deployedBy ?? throw new ArgumentNullException(nameof(deployedBy));
    }
}
