DocSpace-client/common/ASC.Webhooks/Dao/WebhooksDbContext.cs

100 lines
3.4 KiB
C#
Raw Normal View History

using ASC.Core.Common.EF;
using ASC.Webhooks.Dao.Models;
using Microsoft.EntityFrameworkCore;
#nullable disable
namespace ASC.Webhooks.Dao
{
public partial class WebhooksDbContext : BaseDbContext
{
public WebhooksDbContext()
{
}
public WebhooksDbContext(DbContextOptions<WebhooksDbContext> options)
: base(options)
{
}
public virtual DbSet<WebhooksConfig> WebhooksConfigs { get; set; }
public virtual DbSet<WebhooksPayload> WebhooksPayloads { get; set; }
// protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
// {
// if (!optionsBuilder.IsConfigured)
// {
//#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
// optionsBuilder.UseMySQL("server=localhost;port=3306;database=onlyoffice;uid=root;password=onlyoffice");
// }
// }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<WebhooksConfig>(entity =>
{
2021-08-03 16:26:28 +00:00
entity.HasKey(e => new { e.ConfigId})
.HasName("PRIMARY");
entity.ToTable("webhooks_config");
2021-08-03 16:26:28 +00:00
entity.Property(e => e.ConfigId)
.HasColumnType("int")
.HasColumnName("ConfigID");
entity.Property(e => e.TenantId).HasColumnType("int unsigned");
entity.Property(e => e.Uri)
.HasMaxLength(50)
.HasColumnName("URI")
.HasDefaultValueSql("''");
entity.Property(e => e.SecretKey)
.HasMaxLength(50)
.HasColumnName("SecretKey")
.HasDefaultValueSql("''");
});
modelBuilder.Entity<WebhooksPayload>(entity =>
{
entity.HasKey(e => new { e.Id })
.HasName("PRIMARY");
entity.ToTable("webhooks_payload");
entity.Property(e => e.Id)
.HasColumnType("int")
.HasColumnName("ID")
.ValueGeneratedOnAdd();
2021-08-03 16:26:28 +00:00
entity.Property(e => e.ConfigId)
.HasColumnType("int")
.HasColumnName("ConfigID");
entity.Property(e => e.Data)
.IsRequired()
.HasColumnType("json");
entity.Property(e => e.Event)
.HasColumnType("varchar")
.HasColumnName("Event")
2021-08-03 16:26:28 +00:00
.HasMaxLength(100);
entity.Property(e => e.Status)
.HasColumnType("varchar")
.HasColumnName("Status")
.HasMaxLength(50);
entity.Property(e => e.TenantId)
.HasColumnType("int unsigned")
.HasColumnName("TenantID");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
}