DocSpace-buildtools/common/ASC.Core.Common/EF/Model/Tenant/DbButton.cs

81 lines
2.6 KiB
C#
Raw Normal View History

2019-11-29 12:26:53 +00:00
using System.ComponentModel.DataAnnotations.Schema;
2020-09-06 22:49:03 +00:00
using ASC.Core.Common.EF.Model;
2019-12-17 13:01:59 +00:00
using Microsoft.EntityFrameworkCore;
2019-11-29 12:26:53 +00:00
namespace ASC.Core.Common.EF
{
[Table("tenants_buttons")]
2019-12-17 13:01:59 +00:00
public class DbButton : BaseEntity
2019-11-29 12:26:53 +00:00
{
[Column("button_url")]
public string ButtonUrl { get; set; }
[Column("tariff_id")]
public int TariffId { get; set; }
[Column("partner_id")]
public string PartnerId { get; set; }
2019-12-17 13:01:59 +00:00
2020-02-21 12:38:04 +00:00
public override object[] GetKeys()
2019-12-17 13:01:59 +00:00
{
return new object[] { TariffId, PartnerId };
}
}
public static class DbButtonExtension
{
2020-09-06 22:49:03 +00:00
public static ModelBuilderWrapper AddDbButton(this ModelBuilderWrapper modelBuilder)
{
modelBuilder
.Add(MySqlAddDbButton, Provider.MySql)
.Add(PgSqlAddDbButton, Provider.Postrge);
return modelBuilder;
}
public static void MySqlAddDbButton(this ModelBuilder modelBuilder)
2019-12-17 13:01:59 +00:00
{
2020-08-21 02:34:37 +00:00
modelBuilder.Entity<DbButton>(entity =>
{
entity.HasKey(e => new { e.TariffId, e.PartnerId })
.HasName("PRIMARY");
2019-12-17 13:01:59 +00:00
2020-08-21 02:34:37 +00:00
entity.ToTable("tenants_buttons");
entity.Property(e => e.TariffId).HasColumnName("tariff_id");
entity.Property(e => e.PartnerId)
.HasColumnName("partner_id")
.HasColumnType("varchar(50)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.ButtonUrl)
.IsRequired()
.HasColumnName("button_url")
.HasColumnType("text")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
});
}
2020-09-06 22:49:03 +00:00
public static void PgSqlAddDbButton(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<DbButton>(entity =>
{
entity.HasKey(e => new { e.TariffId, e.PartnerId })
.HasName("tenants_buttons_pkey");
entity.ToTable("tenants_buttons", "onlyoffice");
entity.Property(e => e.TariffId).HasColumnName("tariff_id");
entity.Property(e => e.PartnerId)
.HasColumnName("partner_id")
.HasMaxLength(50);
entity.Property(e => e.ButtonUrl)
.IsRequired()
.HasColumnName("button_url");
});
2019-12-17 13:01:59 +00:00
}
2019-11-29 12:26:53 +00:00
}
}