Files
novelly/src/Novelly.Api/Novels/Novel.cs
T
James Wampler 4313c8f206 Rename Project concept to Novel across the stack
Renames the domain concept from Project to Novel throughout the backend
(entities, DTOs, services, endpoints, ProjectAccessService/Permission,
ProjectId foreign keys), MCP server (tool names and routes), and the
React/Vite frontend (types, hooks, routes, components). Adds a new EF
Core migration (RenameProjectToNovel) using RenameTable/RenameColumn to
preserve existing data instead of dropping/recreating tables. Updates
CLAUDE.md's structure section to reference Novels/ instead of Projects/.
2026-08-17 23:03:09 -07:00

62 lines
2.3 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Novelly.Api.Agent;
using Novelly.Api.Chapters;
using Novelly.Api.Characters;
using Novelly.Api.Tags;
using Novelly.Api.Users;
namespace Novelly.Api.Novels;
public class Novel
{
public Guid Id { get; set; } = Guid.NewGuid();
public string Title { get; set; } = string.Empty;
public string? Author { get; set; }
public string? Genre { get; set; }
public string? Logline { get; set; }
public string? Synopsis { get; set; }
public string? Notes { get; set; }
public int? TargetWordCount { get; set; }
public NovelPhase Phase { get; set; } = NovelPhase.Brainstorming;
public Guid? OwnerId { get; set; }
public NovellyUser? Owner { get; set; }
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow;
public List<Character> Characters { get; set; } = [];
public List<Chapter> Chapters { get; set; } = [];
public List<Tag> Tags { get; set; } = [];
public List<AgentConversation> Conversations { get; set; } = [];
public List<NovelMember> Members { get; set; } = [];
}
public class NovelEntityTypeConfiguration : IEntityTypeConfiguration<Novel>
{
public void Configure(EntityTypeBuilder<Novel> entity)
{
entity.Property(p => p.Title).IsRequired().HasMaxLength(300);
entity.Property(p => p.Phase).HasConversion<string>().HasMaxLength(32);
entity.HasMany(p => p.Characters).WithOne(c => c.Novel!)
.HasForeignKey(c => c.NovelId).OnDelete(DeleteBehavior.Cascade);
entity.HasMany(p => p.Chapters).WithOne(c => c.Novel!)
.HasForeignKey(c => c.NovelId).OnDelete(DeleteBehavior.Cascade);
entity.HasMany(p => p.Tags).WithOne(t => t.Novel!)
.HasForeignKey(t => t.NovelId).OnDelete(DeleteBehavior.Cascade);
entity.HasMany(p => p.Conversations).WithOne(c => c.Novel!)
.HasForeignKey(c => c.NovelId).OnDelete(DeleteBehavior.Cascade);
entity.HasMany(p => p.Members).WithOne(m => m.Novel!)
.HasForeignKey(m => m.NovelId).OnDelete(DeleteBehavior.Cascade);
entity.HasOne(p => p.Owner).WithMany()
.HasForeignKey(p => p.OwnerId).OnDelete(DeleteBehavior.Restrict);
}
}