aboutsummaryrefslogtreecommitdiff
path: root/lib/Emails.Transactional.Plugin/src/EmailDbCtx.cs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Emails.Transactional.Plugin/src/EmailDbCtx.cs')
-rw-r--r--lib/Emails.Transactional.Plugin/src/EmailDbCtx.cs84
1 files changed, 21 insertions, 63 deletions
diff --git a/lib/Emails.Transactional.Plugin/src/EmailDbCtx.cs b/lib/Emails.Transactional.Plugin/src/EmailDbCtx.cs
index a88f35c..6f9b051 100644
--- a/lib/Emails.Transactional.Plugin/src/EmailDbCtx.cs
+++ b/lib/Emails.Transactional.Plugin/src/EmailDbCtx.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2023 Vaughn Nugent
+* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: Emails.Transactional
@@ -31,9 +31,7 @@ using VNLib.Plugins.Extensions.Loading.Sql;
namespace Emails.Transactional
{
-
-
- internal class EmailDbCtx : DBContextBase, IDbTableDefinition
+ internal sealed class EmailDbCtx : DBContextBase, IDbTableDefinition
{
public DbSet<EmailTransaction> EmailTransactions { get; set; }
@@ -45,65 +43,25 @@ namespace Emails.Transactional
public void OnDatabaseCreating(IDbContextBuilder builder, object? userState)
{
- //Define email tables
- builder.DefineTable<EmailTransaction>(nameof(EmailTransactions))
-
- //Start with id, its a primary key
- .WithColumn(e => e.Id)
- .MaxLength(50)
- .Next()
-
- .WithColumn(e => e.Created)
- .AllowNull(false)
- .Next()
-
- .WithColumn(e => e.LastModified)
- .AllowNull(false)
- .Next()
-
- .WithColumn(e => e.UserId)
- .MaxLength(100)
- .Next()
-
- //To is allowed to be null
- .WithColumn(e => e.To)
- .MaxLength(1000)
- .Next()
-
- .WithColumn(e => e.From)
- .MaxLength(100)
- .Next()
-
- .WithColumn(e => e.FromName)
- .MaxLength(100)
- .Next()
-
- .WithColumn(e => e.Subject)
- .MaxLength(500)
- .Next()
-
- .WithColumn(e => e.Ccs)
- .MaxLength(1000)
- .Next()
-
- .WithColumn(e => e.Bccs)
- .MaxLength(1000)
- .Next()
-
- .WithColumn(e => e.ReplyTo)
- .MaxLength(100)
- .Next()
-
- .WithColumn(e => e.ReplyToName)
- .MaxLength(100)
- .Next()
-
- .WithColumn(e => e.TemplateId)
- .MaxLength(100)
- .Next()
-
- .WithColumn(e => e.Result)
- .MaxLength(200);
+ //Define the transaction table
+ builder.DefineTable<EmailTransaction>(nameof(EmailTransactions), table =>
+ {
+ table.WithColumn(e => e.Id).AllowNull(false);
+ table.WithColumn(e => e.Created);
+ table.WithColumn(e => e.LastModified);
+ table.WithColumn(e => e.Version);
+ table.WithColumn(e => e.UserId).AllowNull(false);
+ table.WithColumn(e => e.To).MaxLength(1000);
+ table.WithColumn(e => e.From).MaxLength(100);
+ table.WithColumn(e => e.FromName).MaxLength(100);
+ table.WithColumn(e => e.Subject).MaxLength(500);
+ table.WithColumn(e => e.Ccs).MaxLength(1000);
+ table.WithColumn(e => e.Bccs).MaxLength(1000);
+ table.WithColumn(e => e.ReplyTo).MaxLength(100);
+ table.WithColumn(e => e.ReplyToName).MaxLength(100);
+ table.WithColumn(e => e.TemplateId).MaxLength(100);
+ table.WithColumn(e => e.Result).MaxLength(200);
+ });
}
}
}