Skip to content

Commit

Permalink
add unique constraint on award shortname, and add some constraints an…
Browse files Browse the repository at this point in the history
…d nullability override for user username/normalized username and role name
  • Loading branch information
adelikat committed Feb 17, 2024
1 parent 44c97e1 commit 7ecc715
Show file tree
Hide file tree
Showing 8 changed files with 3,631 additions and 1 deletion.
5 changes: 5 additions & 0 deletions TASVideos.Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ protected override void OnModelCreating(ModelBuilder builder)
builder.HasPostgresExtension("pg_trgm");
}

builder.Entity<Award>(entity =>
{
entity.HasIndex(e => e.ShortName).IsUnique();
});

builder.Entity<User>(entity =>
{
entity.HasIndex(e => e.NormalizedUserName).IsUnique();
Expand Down
7 changes: 7 additions & 0 deletions TASVideos.Data/Entity/Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ namespace TASVideos.Data.Entity;

public class Role : IdentityRole<int>, ITrackable
{
[StringLength(50)]
public new string Name
{
get => base.Name!;
set => base.Name = value;
}

/// <summary>
/// Gets or sets a value indicating whether the role is automatically assigned to new users.
/// </summary>
Expand Down
14 changes: 14 additions & 0 deletions TASVideos.Data/Entity/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ public enum UserPreference

public class User : IdentityUser<int>, ITrackable
{
[StringLength(50)]
public new string UserName
{
get => base.UserName!;
set => base.UserName = value;
}

[StringLength(50)]
public new string NormalizedUserName
{
get => base.NormalizedUserName!;
set => base.NormalizedUserName = value;
}

public DateTime? LastLoggedInTimeStamp { get; set; }

[Required]
Expand Down
Loading

0 comments on commit 7ecc715

Please sign in to comment.