8b0451c2ec
This commit enhances the Note entity by introducing two new properties: IsPinned and IsDeleted, allowing for better management of note visibility and status. The NoteConfiguration class has been updated to include indexes for these properties, improving query performance. Additionally, new migrations have been created to reflect these changes in the database schema. The UI components have been updated to support pinning and restoring notes, enhancing user interaction and functionality within the note management system.
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using Core.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Data.Configurations
|
|
{
|
|
public class NoteConfiguration : IEntityTypeConfiguration<Note>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Note> builder)
|
|
{
|
|
builder.HasKey(n => n.Id);
|
|
|
|
// Indexes
|
|
builder.HasIndex(n => n.Title);
|
|
builder.HasIndex(n => n.CreatedAt);
|
|
builder.HasIndex(n => n.IsPinned);
|
|
builder.HasIndex(n => n.IsDeleted);
|
|
|
|
// Constraints
|
|
builder.Property(n => n.Title)
|
|
.IsRequired()
|
|
.HasMaxLength(200);
|
|
|
|
builder.Property(n => n.Content)
|
|
.HasColumnType("TEXT");
|
|
|
|
builder.Property(n => n.CreatedBy)
|
|
.HasMaxLength(255);
|
|
|
|
builder.Property(n => n.LastModifiedBy)
|
|
.HasMaxLength(255);
|
|
|
|
// Relationships
|
|
builder.HasMany(n => n.NoteHistories)
|
|
.WithOne(h => h.Note)
|
|
.HasForeignKey(h => h.NoteId)
|
|
.IsRequired()
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
}
|
|
}
|