28 lines
1.0 KiB
C#
28 lines
1.0 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Socialize.Api.Modules.Campaigns.Data;
|
|
|
|
public static class CampaignModelConfiguration
|
|
{
|
|
public static ModelBuilder ConfigureCampaignsModule(this ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Campaign>(campaign =>
|
|
{
|
|
campaign.ToTable("Campaigns");
|
|
campaign.HasKey(x => x.Id);
|
|
campaign.Property(x => x.Name).HasMaxLength(256).IsRequired();
|
|
campaign.Property(x => x.Description).HasMaxLength(4000);
|
|
campaign.Property(x => x.Notes).HasMaxLength(4000);
|
|
campaign.Property(x => x.Status).HasMaxLength(64).IsRequired();
|
|
campaign.Property(x => x.CreatedAt)
|
|
.ValueGeneratedOnAdd()
|
|
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
|
campaign.HasIndex(x => new { x.ClientId, x.Name }).IsUnique();
|
|
campaign.HasIndex(x => x.WorkspaceId);
|
|
campaign.HasIndex(x => x.ClientId);
|
|
});
|
|
|
|
return modelBuilder;
|
|
}
|
|
}
|