void.cat/VoidCat/Database/Configurations/UserConfiguration.cs
Kieran 4de977c1dd v5 (#65)
Co-authored-by: Kieran <kieran@harkin.me>
Reviewed-on: Kieran/void.cat#65
2023-05-09 13:56:57 +00:00

39 lines
1004 B
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace VoidCat.Database.Configurations;
public class UserConfiguration : IEntityTypeConfiguration<User>
{
public void Configure(EntityTypeBuilder<User> builder)
{
builder.ToTable("Users");
builder.HasKey(a => a.Id);
builder.Property(a => a.Email)
.IsRequired();
builder.Property(a => a.Password)
.IsRequired(false);
builder.Property(a => a.Created)
.IsRequired();
builder.Property(a => a.LastLogin);
builder.Property(a => a.DisplayName)
.IsRequired()
.HasDefaultValue("void user");
builder.Property(a => a.Flags)
.IsRequired();
builder.Property(a => a.Storage)
.IsRequired()
.HasDefaultValue("local-disk");
builder.Property(a => a.AuthType)
.IsRequired();
builder.HasIndex(a => a.Email);
}
}