//----------------------------------------------------------------------- // // Copyright (c) aliasvault. All rights reserved. // Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information. // //----------------------------------------------------------------------- namespace AliasClientDb; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using AliasClientDb.Abstracts; /// /// FieldHistory entity that stores historical snapshots of field values. /// public class FieldHistory : SyncableEntity { /// /// Gets or sets the field history ID. /// [Key] public Guid Id { get; set; } /// /// Gets or sets the item ID. /// [Required] public Guid ItemId { get; set; } /// /// Gets or sets the item object. /// [ForeignKey("ItemId")] public virtual Item Item { get; set; } = null!; /// /// Gets or sets the field definition ID for custom (user-defined) fields. /// NULL for system fields (which use FieldKey instead). /// public Guid? FieldDefinitionId { get; set; } /// /// Gets or sets the field definition object for custom fields. /// NULL for system fields. /// [ForeignKey("FieldDefinitionId")] public virtual FieldDefinition? FieldDefinition { get; set; } /// /// Gets or sets the system field key for predefined fields (e.g., 'login.password'). /// NULL for custom (user-defined) fields (which use FieldDefinitionId instead). /// System field metadata is defined in code (SystemFieldRegistry), not in the database. /// Note: Exactly one of FieldKey or FieldDefinitionId must be non-null. /// [StringLength(100)] public string? FieldKey { get; set; } /// /// Gets or sets the value snapshot as JSON (e.g., '["oldpassword"]'). /// For multi-value fields, this stores an array of values. /// [Required] public string ValueSnapshot { get; set; } = string.Empty; /// /// Gets or sets the timestamp when this value was changed. /// [Required] public DateTime ChangedAt { get; set; } }