Skip to content

Commit

Permalink
template: Constrain generated TenantId SQL field size (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamskt authored Nov 14, 2024
1 parent 58699f0 commit 1b75edf
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class UserInfo
public required ICollection<string> Permissions { get; set; }
#endif
#if Tenancy
[MaxLength(36)]
public string? TenantId { get; set; }
public string? TenantName { get; set; }
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
global using Coalesce.Starter.Vue.Data.Auth;
global using Coalesce.Starter.Vue.Data.Coalesce;
global using Coalesce.Starter.Vue.Data.Utilities;
#if (Identity || ExampleModel)
#if (Identity || ExampleModel || TrackingBase)
global using Coalesce.Starter.Vue.Data.Models;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class AuditLog : DefaultAuditLog
// NOTE: Audit logs are *optionally* tenanted because they can log changes
// to non-tenanted entities as well. Read security is implemented in the below datasource.

[InternalUse]
[InternalUse, MaxLength(36)]
public string? TenantId { get; set; }
[InternalUse]
public Tenant? Tenant { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Role
#if Tenancy
[InternalUse]
[DefaultOrderBy(FieldOrder = 0)]
[MaxLength(36)]
public string TenantId { get; set; } = null!;
[InternalUse]
[ForeignKey(nameof(TenantId))]
Expand Down Expand Up @@ -62,6 +63,7 @@ public class RoleClaim : IdentityRoleClaim<string>, ITenanted

[InternalUse]
[DefaultOrderBy(FieldOrder = 0)]
[MaxLength(36)]
public required string TenantId { get; set; }
[InternalUse]
[ForeignKey(nameof(TenantId))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Coalesce.Starter.Vue.Data.Models;
[Display(Name = "Organization")]
public class Tenant
{
[MaxLength(36)]
public string TenantId { get; set; } = Guid.NewGuid().ToString();

public required string Name { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[InternalUse]
public class TenantMembership : TenantedBase
{
[MaxLength(36)]
public string TenantMembershipId { get; set; } = Guid.NewGuid().ToString();

[Required]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public abstract class TenantedBase
: ITenanted
#endif
{
[InternalUse, Required]
[InternalUse, Required, MaxLength(36)]
public string TenantId { get; set; } = null!;
[InternalUse]
public Tenant? Tenant { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public string Id
#if Tenancy
[InternalUse]
[DefaultOrderBy(FieldOrder = 0)]
[MaxLength(36)]
public string TenantId { get; set; } = null!;
[InternalUse]
public Tenant? Tenant { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@*#if (AppInsights)
@*#if (AppInsights)
@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
#endif*@
@namespace Coalesce.Starter.Vue.Web.Pages

<!DOCTYPE html>
<html lang="en">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#if OpenAPI
using Microsoft.OpenApi.Models;
#endif
using System.Security.Claims;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
Expand Down

0 comments on commit 1b75edf

Please sign in to comment.