package com.agent.management.model.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Index;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import lombok.Data;

import java.time.Instant;

@Data
@Entity
@Table(name = "rag_structured_schema_profile",
        uniqueConstraints = @UniqueConstraint(name = "uk_rag_structured_profile_source",
                columnNames = {"data_source_id", "catalog_name", "schema_name"}),
        indexes = @Index(name = "idx_rag_structured_profile_fingerprint",
                columnList = "data_source_id,source_fingerprint,schema_fingerprint,algorithm_version"))
public class RagStructuredSchemaProfileEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "data_source_id", nullable = false)
    private Long dataSourceId;

    @Column(name = "catalog_name", nullable = false, length = 200)
    private String catalogName = "";

    @Column(name = "schema_name", nullable = false, length = 200)
    private String schemaName = "";

    @Column(name = "profile_json", nullable = false, columnDefinition = "CLOB")
    private String profileJson;

    @Column(name = "source_fingerprint", nullable = false, length = 64)
    private String sourceFingerprint;

    @Column(name = "schema_fingerprint", nullable = false, length = 64)
    private String schemaFingerprint;

    @Column(name = "algorithm_version", nullable = false, length = 40)
    private String algorithmVersion;

    @Column(name = "scan_status", nullable = false, length = 20)
    private String scanStatus;

    @Column(name = "scanned_at", nullable = false)
    private Instant scannedAt;

    @Column(name = "last_error", length = 1000)
    private String lastError;
}
