voidkitty/VoidCat/Database/Configurations/FileConfiguration.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

40 lines
1.1 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace VoidCat.Database.Configurations;
public class FileConfiguration : IEntityTypeConfiguration<File>
{
public void Configure(EntityTypeBuilder<File> builder)
{
builder.ToTable("Files");
builder.HasKey(a => a.Id);
builder.Property(a => a.Name);
builder.Property(a => a.Size)
.IsRequired();
builder.Property(a => a.Uploaded)
.IsRequired();
builder.Property(a => a.Description);
builder.Property(a => a.MimeType)
.IsRequired()
.HasDefaultValue("application/octet-stream");
builder.Property(a => a.Digest);
builder.Property(a => a.EditSecret)
.IsRequired();
builder.Property(a => a.Expires);
builder.Property(a => a.Storage)
.IsRequired()
.HasDefaultValue("local-disk");
builder.Property(a => a.EncryptionParams);
builder.Property(a => a.MagnetLink);
builder.HasIndex(a => a.Uploaded);
}
}