Add calendar integrations and collaboration updates
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Socialize.Api.Modules.CalendarIntegrations.Data;
|
||||
|
||||
public static class CalendarSourceModelConfiguration
|
||||
{
|
||||
public static ModelBuilder ConfigureCalendarIntegrationsModule(this ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<CalendarSource>(source =>
|
||||
{
|
||||
source.ToTable("CalendarSources");
|
||||
source.HasKey(x => x.Id);
|
||||
source.Property(x => x.Scope).HasMaxLength(32).IsRequired();
|
||||
source.Property(x => x.SourceUrl).HasMaxLength(2048);
|
||||
source.Property(x => x.CatalogSourceReference).HasMaxLength(256);
|
||||
source.Property(x => x.DisplayTitle).HasMaxLength(256).IsRequired();
|
||||
source.Property(x => x.Color).HasMaxLength(16).IsRequired();
|
||||
source.Property(x => x.Category).HasMaxLength(64).IsRequired();
|
||||
source.Property(x => x.InheritanceMode).HasMaxLength(32);
|
||||
source.Property(x => x.LastSyncError).HasMaxLength(2048);
|
||||
source.Property(x => x.CreatedAt)
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||
source.Property(x => x.UpdatedAt)
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||
|
||||
source.HasIndex(x => x.Scope);
|
||||
source.HasIndex(x => x.OrganizationId);
|
||||
source.HasIndex(x => x.WorkspaceId);
|
||||
source.HasIndex(x => x.UserId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CalendarCatalogEntry>(entry =>
|
||||
{
|
||||
entry.ToTable("CalendarCatalogEntries");
|
||||
entry.HasKey(x => x.Id);
|
||||
entry.Property(x => x.Title).HasMaxLength(256).IsRequired();
|
||||
entry.Property(x => x.Description).HasMaxLength(1024).IsRequired();
|
||||
entry.Property(x => x.Country).HasMaxLength(2);
|
||||
entry.Property(x => x.Region).HasMaxLength(128);
|
||||
entry.Property(x => x.Language).HasMaxLength(16).IsRequired();
|
||||
entry.Property(x => x.Category).HasMaxLength(64).IsRequired();
|
||||
entry.Property(x => x.CultureOrReligion).HasMaxLength(128);
|
||||
entry.Property(x => x.ProviderName).HasMaxLength(128).IsRequired();
|
||||
entry.Property(x => x.SourceUrl).HasMaxLength(2048).IsRequired();
|
||||
entry.Property(x => x.TrustLevel).HasMaxLength(64).IsRequired();
|
||||
entry.Property(x => x.DefaultColor).HasMaxLength(16).IsRequired();
|
||||
entry.Property(x => x.CreatedAt)
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||
entry.HasIndex(x => x.Country);
|
||||
entry.HasIndex(x => x.Category);
|
||||
entry.HasIndex(x => x.ProviderName);
|
||||
entry.HasData(CalendarCatalogSeed.Entries);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CalendarEvent>(calendarEvent =>
|
||||
{
|
||||
calendarEvent.ToTable("CalendarEvents");
|
||||
calendarEvent.HasKey(x => x.Id);
|
||||
calendarEvent.Property(x => x.SourceEventUid).HasMaxLength(512).IsRequired();
|
||||
calendarEvent.Property(x => x.Title).HasMaxLength(512).IsRequired();
|
||||
calendarEvent.Property(x => x.Description).HasMaxLength(4000);
|
||||
calendarEvent.Property(x => x.TimeZoneId).HasMaxLength(128);
|
||||
calendarEvent.Property(x => x.RecurrenceId).HasMaxLength(512);
|
||||
calendarEvent.Property(x => x.Location).HasMaxLength(512);
|
||||
calendarEvent.Property(x => x.SourceUrl).HasMaxLength(2048);
|
||||
calendarEvent.HasIndex(x => x.CalendarSourceId);
|
||||
calendarEvent.HasIndex(x => new { x.CalendarSourceId, x.SourceEventUid, x.StartDate }).IsUnique();
|
||||
calendarEvent.HasOne<CalendarSource>()
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.CalendarSourceId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<UserCalendarExportFeed>(feed =>
|
||||
{
|
||||
feed.ToTable("UserCalendarExportFeeds");
|
||||
feed.HasKey(x => x.Id);
|
||||
feed.Property(x => x.Token).HasMaxLength(96);
|
||||
feed.Property(x => x.TokenHash).HasMaxLength(64);
|
||||
feed.Property(x => x.CreatedAt)
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||
feed.Property(x => x.UpdatedAt)
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||
feed.HasIndex(x => x.UserId).IsUnique();
|
||||
feed.HasIndex(x => x.TokenHash).IsUnique();
|
||||
});
|
||||
|
||||
return modelBuilder;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user