DocSpace-buildtools/common/ASC.Core.Common/EF/Model/Resource/ResFiles.cs

116 lines
4.1 KiB
C#
Raw Normal View History

2020-08-21 02:34:37 +00:00
using Microsoft.EntityFrameworkCore;
using System;
2019-12-16 09:30:01 +00:00
using System.ComponentModel.DataAnnotations.Schema;
namespace ASC.Core.Common.EF.Model.Resource
{
[Table("res_files")]
public class ResFiles
{
public int Id { get; set; }
public string ProjectName { get; set; }
public string ModuleName { get; set; }
public string ResName { get; set; }
public bool IsLock { get; set; }
public DateTime LastUpdate { get; set; }
public DateTime CreationDate { get; set; }
}
2020-08-21 02:34:37 +00:00
public static class ResFilesExtension
{
2020-09-06 22:49:03 +00:00
public static ModelBuilderWrapper AddResFiles(this ModelBuilderWrapper modelBuilder)
{
modelBuilder
.Add(MySqlAddResFiles, Provider.MySql)
2020-10-08 09:07:05 +00:00
.Add(PgSqlAddResFiles, Provider.Postgre);
2020-09-06 22:49:03 +00:00
return modelBuilder;
}
public static void MySqlAddResFiles(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<ResFiles>(entity =>
{
entity.ToTable("res_files");
entity.HasIndex(e => e.ResName)
.HasName("resname")
.IsUnique();
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.CreationDate)
.HasColumnName("creationDate")
.HasColumnType("timestamp")
.HasDefaultValueSql("'0000-00-00 00:00:00'");
entity.Property(e => e.IsLock).HasColumnName("isLock");
entity.Property(e => e.LastUpdate)
.HasColumnName("lastUpdate")
.HasColumnType("timestamp")
.HasDefaultValueSql("CURRENT_TIMESTAMP")
.ValueGeneratedOnAddOrUpdate();
entity.Property(e => e.ModuleName)
.IsRequired()
.HasColumnName("moduleName")
.HasColumnType("varchar(50)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.ProjectName)
.IsRequired()
.HasColumnName("projectName")
.HasColumnType("varchar(50)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
entity.Property(e => e.ResName)
.IsRequired()
.HasColumnName("resName")
.HasColumnType("varchar(50)")
.HasCharSet("utf8")
.HasCollation("utf8_general_ci");
});
}
2020-09-06 22:49:03 +00:00
public static void PgSqlAddResFiles(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<ResFiles>(entity =>
{
entity.ToTable("res_files", "onlyoffice");
entity.HasIndex(e => e.ResName)
.HasName("resname")
.IsUnique();
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.CreationDate)
.HasColumnName("creationDate")
2020-09-29 17:09:39 +00:00
.HasDefaultValueSql("'1975-03-03 00:00:00'");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.IsLock)
.HasColumnName("isLock")
2020-09-06 22:49:03 +00:00
.HasDefaultValueSql("'0'");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.LastUpdate)
.HasColumnName("lastUpdate")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
entity.Property(e => e.ModuleName)
.IsRequired()
.HasColumnName("moduleName")
.HasMaxLength(50);
entity.Property(e => e.ProjectName)
.IsRequired()
.HasColumnName("projectName")
.HasMaxLength(50);
entity.Property(e => e.ResName)
.IsRequired()
.HasColumnName("resName")
.HasMaxLength(50);
});
}
}
2019-12-16 09:30:01 +00:00
}