DocSpace-client/common/ASC.Core.Common/EF/Model/Tenant/TenantIpRestrictions.cs

66 lines
2.2 KiB
C#
Raw Normal View History

2020-08-21 02:34:37 +00:00
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
2019-12-10 14:47:48 +00:00
namespace ASC.Core.Common.EF.Model
{
[Table("tenants_iprestrictions")]
public class TenantIpRestrictions
{
public int Id { get; set; }
public int Tenant { get; set; }
public string Ip { get; set; }
}
2020-08-21 02:34:37 +00:00
public static class TenantIpRestrictionsExtension
{
2020-09-06 22:49:03 +00:00
public static ModelBuilderWrapper AddTenantIpRestrictions(this ModelBuilderWrapper modelBuilder)
{
modelBuilder
.Add(MySqlAddTenantIpRestrictions, Provider.MySql)
2020-10-08 09:07:05 +00:00
.Add(PgSqlAddTenantIpRestrictions, Provider.Postgre);
2020-09-06 22:49:03 +00:00
return modelBuilder;
}
2020-08-21 02:34:37 +00:00
public static void MySqlAddTenantIpRestrictions(this ModelBuilder modelBuilder)
{
modelBuilder.Entity<TenantIpRestrictions>(entity =>
{
entity.ToTable("tenants_iprestrictions");
entity.HasIndex(e => e.Tenant)
.HasName("tenant");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.Ip)
.IsRequired()
.HasColumnName("ip")
.HasColumnType("varchar(50)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.Tenant).HasColumnName("tenant");
});
}
public static void PgSqlAddTenantIpRestrictions(this ModelBuilder modelBuilder)
{
modelBuilder.Entity<TenantIpRestrictions>(entity =>
{
entity.ToTable("tenants_iprestrictions", "onlyoffice");
entity.HasIndex(e => e.Tenant)
.HasName("tenant_tenants_iprestrictions");
2020-09-29 17:09:39 +00:00
entity.Property(e => e.Id).HasColumnName("id");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Ip)
.IsRequired()
.HasColumnName("ip")
.HasMaxLength(50);
entity.Property(e => e.Tenant).HasColumnName("tenant");
});
}
}
2019-12-10 14:47:48 +00:00
}