From b36740899a577ac387f52229c2e714a9f09f2b84 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Mon, 16 Jan 2023 19:40:25 +0100 Subject: refactor: Rename Eva to Db --- src/Db.cs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/Db.cs (limited to 'src/Db.cs') diff --git a/src/Db.cs b/src/Db.cs new file mode 100644 index 0000000..39deefa --- /dev/null +++ b/src/Db.cs @@ -0,0 +1,52 @@ +using Microsoft.EntityFrameworkCore; + +namespace BlobBin; + +public sealed class Db : DbContext +{ + private readonly bool migrated; + + public Db(DbContextOptions options) : base(options) { + if (!migrated) { + Database.Migrate(); + migrated = true; + } + } + + public DbSet Files { get; set; } + public DbSet Pastes { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { + optionsBuilder.UseSqlite("data source = AppData/main.db"); + base.OnConfiguring(optionsBuilder); + } +} + +public class UploadEntityBase +{ + public UploadEntityBase() { + Id = Guid.NewGuid(); + CreatedAt = DateTime.UtcNow; + } + + public Guid Id { get; set; } + public string PublicId { get; set; } + public DateTime CreatedAt { get; set; } + public string CreatedBy { get; set; } + public DateTime? DeletedAt { get; set; } + public string? PasswordHash { get; set; } + public bool Singleton { get; set; } + public string? AutoDeleteAfter { get; set; } + public string? MimeType { get; set; } + public string DeletionKey { get; set; } + public string? Name { get; set; } + public long Length { get; set; } +} + +public class Paste : UploadEntityBase +{ + public string? Content { get; set; } +} + +public class File : UploadEntityBase +{ } \ No newline at end of file -- cgit v1.3