2019-11-29 12:26:53 +00:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2020-10-12 16:23:15 +00:00
|
|
|
|
|
2020-09-06 22:49:03 +00:00
|
|
|
|
using ASC.Core.Common.EF.Model;
|
2020-10-12 16:23:15 +00:00
|
|
|
|
|
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)
|
2019-12-17 13:01:59 +00:00
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
|
modelBuilder
|
2020-09-06 22:49:03 +00:00
|
|
|
|
.Add(MySqlAddDbButton, Provider.MySql)
|
2020-10-08 09:07:05 +00:00
|
|
|
|
.Add(PgSqlAddDbButton, Provider.Postgre);
|
2019-12-17 13:01:59 +00:00
|
|
|
|
return modelBuilder;
|
|
|
|
|
}
|
2020-09-06 22:49:03 +00:00
|
|
|
|
public static void MySqlAddDbButton(this ModelBuilder modelBuilder)
|
2019-12-17 13:01:59 +00:00
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
|
modelBuilder.Entity<DbButton>(entity =>
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
|
entity.HasKey(e => new { e.TariffId, e.PartnerId })
|
2020-08-21 02:34:37 +00:00
|
|
|
|
.HasName("PRIMARY");
|
2019-12-17 13:01:59 +00:00
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
|
entity.ToTable("tenants_buttons");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
|
entity.Property(e => e.TariffId).HasColumnName("tariff_id");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
|
entity.Property(e => e.PartnerId)
|
2020-08-21 02:34:37 +00:00
|
|
|
|
.HasColumnName("partner_id")
|
|
|
|
|
.HasColumnType("varchar(50)")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.HasCollation("utf8_general_ci");
|
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
|
entity.Property(e => e.ButtonUrl)
|
2020-08-21 02:34:37 +00:00
|
|
|
|
.IsRequired()
|
|
|
|
|
.HasColumnName("button_url")
|
|
|
|
|
.HasColumnType("text")
|
|
|
|
|
.HasCharSet("utf8")
|
|
|
|
|
.HasCollation("utf8_general_ci");
|
|
|
|
|
});
|
2020-10-12 16:23:15 +00:00
|
|
|
|
}
|
2020-09-06 22:49:03 +00:00
|
|
|
|
public static void PgSqlAddDbButton(this ModelBuilder modelBuilder)
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
|
modelBuilder.Entity<DbButton>(entity =>
|
2020-08-21 02:34:37 +00:00
|
|
|
|
{
|
2020-10-12 19:39:23 +00:00
|
|
|
|
entity.HasKey(e => new { e.TariffId, e.PartnerId })
|
2020-08-21 02:34:37 +00:00
|
|
|
|
.HasName("tenants_buttons_pkey");
|
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
|
entity.ToTable("tenants_buttons", "onlyoffice");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
|
entity.Property(e => e.TariffId).HasColumnName("tariff_id");
|
2020-08-21 02:34:37 +00:00
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
|
entity.Property(e => e.PartnerId)
|
2020-08-21 02:34:37 +00:00
|
|
|
|
.HasColumnName("partner_id")
|
|
|
|
|
.HasMaxLength(50);
|
|
|
|
|
|
2020-10-12 19:39:23 +00:00
|
|
|
|
entity.Property(e => e.ButtonUrl)
|
2020-08-21 02:34:37 +00:00
|
|
|
|
.IsRequired()
|
|
|
|
|
.HasColumnName("button_url");
|
|
|
|
|
});
|
2019-12-17 13:01:59 +00:00
|
|
|
|
}
|
2019-11-29 12:26:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|