DocSpace-buildtools/common/ASC.Core.Common/EF/Model/Tenant/DbTenantVersion.cs
2020-08-21 05:34:37 +03:00

75 lines
2.4 KiB
C#

using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace ASC.Core.Common.EF.Model
{
[Table("tenants_version")]
public class DbTenantVersion
{
public int Id { get; set; }
public string Version { get; set; }
public string Url { get; set; }
[Column("default_version")]
public int DefaultVersion { get; set; }
public bool Visible { get; set; }
}
public static class DbTenantVersionExtension
{
public static void MySqlAddDbTenantVersion(this ModelBuilder modelBuilder)
{
modelBuilder.Entity<DbTenantVersion>(entity =>
{
entity.ToTable("tenants_version");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.DefaultVersion).HasColumnName("default_version");
entity.Property(e => e.Url)
.IsRequired()
.HasColumnName("url")
.HasColumnType("varchar(64)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.Version)
.IsRequired()
.HasColumnName("version")
.HasColumnType("varchar(64)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.Visible).HasColumnName("visible");
});
}
public static void PgSqlAddDbTenantVersion(this ModelBuilder modelBuilder)
{
modelBuilder.Entity<DbTenantVersion>(entity =>
{
entity.ToTable("tenants_version", "onlyoffice");
entity.Property(e => e.Id)
.HasColumnName("id")
.ValueGeneratedNever();
entity.Property(e => e.DefaultVersion).HasColumnName("default_version");
entity.Property(e => e.Url)
.IsRequired()
.HasColumnName("url")
.HasMaxLength(64);
entity.Property(e => e.Version)
.IsRequired()
.HasColumnName("version")
.HasMaxLength(64);
entity.Property(e => e.Visible).HasColumnName("visible");
});
}
}
}