Files
jobtrackingapp/JobTrackerApi/Models/CoverLetterVersion.cs
T
cesnimda 934b35a1e0 refactor(db): migrate cover letter history
Move append-only cover letter revisions into an additive provider-aware migration. Preserve manual and AI text, source metadata, ordering, and application cascade semantics.
2026-08-30 18:55:20 +02:00

42 lines
1.6 KiB
C#

namespace JobTrackerApi.Models;
// Phase 5.4 — Application Assets.
//
// Append-only history for a job application's cover letter. JobApplication.CoverLetterText stays the
// CURRENT text and the existing API contract around it is unchanged; this only records what it used
// to be, so an AI rewrite or a bad edit is never destructive. Mirrors CvVariantVersion: restore
// re-saves an old snapshot as a new version rather than rewinding.
//
// Migration-owned; the historical no-op is followed by an additive provider-aware adoption.
public sealed class CoverLetterVersion
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public int JobApplicationId { get; set; }
public JobApplication? JobApplication { get; set; }
public int Version { get; set; }
public string Text { get; set; } = string.Empty;
// manual | ai | template | restore — how this text came to exist, so the history list can show
// whether the user wrote it or approved it from a suggestion.
public string Source { get; set; } = "manual";
// For an AI-sourced version: which action produced it (generate | improve | shorten | expand |
// tone | tailor). Null for anything the user typed.
public string? AiAction { get; set; }
public DateTimeOffset CreatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
}
public static class CoverLetterSources
{
public const string Manual = "manual";
public const string Ai = "ai";
public const string Template = "template";
public const string Restore = "restore";
public static bool IsValid(string? value) =>
value is Manual or Ai or Template or Restore;
}