diff options
author | vnugent <public@vaughnnugent.com> | 2024-03-30 22:11:13 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-03-30 22:11:13 -0400 |
commit | 50f2cf42fdb4eafbfff6f5628cc46074bf2d1eaf (patch) | |
tree | 7d0ba6fea196f54626d2948812fd6b857910f825 | |
parent | fa2a9ce15af0aabe36d4e488d5c079723f9796fe (diff) |
chore: Impletment SQL loading api updates
-rw-r--r-- | lib/Emails.Transactional.Plugin/src/EmailDbCtx.cs | 84 | ||||
-rw-r--r-- | lib/Emails.Transactional.Plugin/src/EmailTransaction.cs | 2 |
2 files changed, 23 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); + }); } } } diff --git a/lib/Emails.Transactional.Plugin/src/EmailTransaction.cs b/lib/Emails.Transactional.Plugin/src/EmailTransaction.cs index 5ce2040..dbc0ad6 100644 --- a/lib/Emails.Transactional.Plugin/src/EmailTransaction.cs +++ b/lib/Emails.Transactional.Plugin/src/EmailTransaction.cs @@ -43,6 +43,7 @@ namespace Emails.Transactional { ///<inheritdoc/> [Key] + [MaxLength(64)] [JsonPropertyName("id")] public override string Id { get; set; } ///<inheritdoc/> @@ -56,6 +57,7 @@ namespace Emails.Transactional /// The sever side user-id that send the email /// </summary> [JsonIgnore] + [MaxLength(64)] public string? UserId { get; set; } //To address |