aboutsummaryrefslogtreecommitdiff
path: root/lib/Emails.Transactional.Plugin/src/EmailDbCtx.cs
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-03-30 22:11:13 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-03-30 22:11:13 -0400
commit50f2cf42fdb4eafbfff6f5628cc46074bf2d1eaf (patch)
tree7d0ba6fea196f54626d2948812fd6b857910f825 /lib/Emails.Transactional.Plugin/src/EmailDbCtx.cs
parentfa2a9ce15af0aabe36d4e488d5c079723f9796fe (diff)
chore: Impletment SQL loading api updates
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);
+ });
}
}
}