Split creators out of identity

This commit is contained in:
Jonathan Bourdon
2024-07-31 23:29:26 -04:00
parent bbcc7a8a33
commit 2b30e1a03c
105 changed files with 1497 additions and 7490 deletions

View File

@@ -7,17 +7,50 @@ public class ContentDbContext(
: DbContext(options)
{
public const string SchemaName = "Content";
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("Content");
modelBuilder
.Entity<Content>()
.Property(c => c.CreatedAt)
.ValueGeneratedOnAdd()
.HasDefaultValueSql("CURRENT_TIMESTAMP");
modelBuilder
.Entity<Creator>()
.OwnsOne<About>(x => x.About);
modelBuilder
.Entity<Creator>()
.OwnsOne<SocialNetworks>(x => x.SocialNetworks);
modelBuilder
.Entity<Creator>()
.OwnsOne<ProfileColors>(x => x.ProfileColors);
modelBuilder
.Entity<Creator>()
.OwnsOne<StoredDataUrls>(x => x.StoredDataUrls);
}
public DbSet<Content> Contents { get; set; }
public DbSet<Content> Contents { get; init; } = null!;
public DbSet<Creator> Creators { get; init; } = null!;
public async Task<Creator?> FindByCreatorAliasAsync(
string creatorAlias,
CancellationToken cancellationToken = default)
{
ArgumentException.ThrowIfNullOrEmpty(creatorAlias);
var user = await Creators.SingleOrDefaultAsync(creator =>
EF.Functions.Like(
creatorAlias,
creator.Name),
cancellationToken: cancellationToken);
return user;
}
}