limiting field lengths phase 1

This commit is contained in:
Hamid Reza Mohammadi 2024-12-19 11:05:12 +03:30
parent 19a2ce65e8
commit 66f6de4632
6 changed files with 6278 additions and 14 deletions

View File

@ -17,6 +17,7 @@ using System.IO;
using RMuseum.Models.FAQ;
using RMuseum.Models.PDFLibrary;
using RMuseum.Models.ExternalFTPUpload;
using Microsoft.EntityFrameworkCore.Diagnostics;
namespace RMuseum.DbContext
{
@ -205,6 +206,51 @@ namespace RMuseum.DbContext
.IsUnique();
builder.Entity<GanjoorVerse>()
.Property(e => e.CoupletSummary)
.HasMaxLength(4000);
builder.Entity<GanjoorPoem>()
.Property(e => e.Title)
.HasMaxLength(1500);
builder.Entity<GanjoorPoem>()
.Property(e => e.FullTitle)
.HasMaxLength(1500);
builder.Entity<GanjoorPoem>()
.Property(e => e.UrlSlug)
.HasMaxLength(32);
builder.Entity<GanjoorPoem>()
.Property(e => e.RhymeLetters)
.HasMaxLength(64);
builder.Entity<GanjoorPoem>()
.Property(e => e.SourceName)
.HasMaxLength(64);
builder.Entity<GanjoorPoem>()
.Property(e => e.SourceUrlSlug)
.HasMaxLength(16);
builder.Entity<GanjoorPoem>()
.Property(e => e.OldTag)
.HasMaxLength(16);
builder.Entity<GanjoorPoem>()
.Property(e => e.OldTagPageUrl)
.HasMaxLength(32);
builder.Entity<GanjoorPoem>()
.Property(e => e.Language)
.HasMaxLength(8);
builder.Entity<GanjoorPoem>()
.Property(e => e.PoemSummary)
.HasMaxLength(3000);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,238 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace RMuseum.Migrations
{
/// <inheritdoc />
public partial class LimitedFieldLengths1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "CoupletSummary",
table: "GanjoorVerses",
type: "nvarchar(4000)",
maxLength: 4000,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "UrlSlug",
table: "GanjoorPoems",
type: "nvarchar(32)",
maxLength: 32,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Title",
table: "GanjoorPoems",
type: "nvarchar(1500)",
maxLength: 1500,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "SourceUrlSlug",
table: "GanjoorPoems",
type: "nvarchar(16)",
maxLength: 16,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "SourceName",
table: "GanjoorPoems",
type: "nvarchar(64)",
maxLength: 64,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RhymeLetters",
table: "GanjoorPoems",
type: "nvarchar(64)",
maxLength: 64,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "PoemSummary",
table: "GanjoorPoems",
type: "nvarchar(3000)",
maxLength: 3000,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "OldTagPageUrl",
table: "GanjoorPoems",
type: "nvarchar(32)",
maxLength: 32,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "OldTag",
table: "GanjoorPoems",
type: "nvarchar(16)",
maxLength: 16,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Language",
table: "GanjoorPoems",
type: "nvarchar(8)",
maxLength: 8,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "FullTitle",
table: "GanjoorPoems",
type: "nvarchar(1500)",
maxLength: 1500,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "CoupletSummary",
table: "GanjoorVerses",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(4000)",
oldMaxLength: 4000,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "UrlSlug",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(32)",
oldMaxLength: 32,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Title",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(1500)",
oldMaxLength: 1500,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "SourceUrlSlug",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(16)",
oldMaxLength: 16,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "SourceName",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(64)",
oldMaxLength: 64,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "RhymeLetters",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(64)",
oldMaxLength: 64,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "PoemSummary",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(3000)",
oldMaxLength: 3000,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "OldTagPageUrl",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(32)",
oldMaxLength: 32,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "OldTag",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(16)",
oldMaxLength: 16,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Language",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(8)",
oldMaxLength: 8,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "FullTitle",
table: "GanjoorPoems",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(1500)",
oldMaxLength: 1500,
oldNullable: true);
}
}
}

View File

@ -17,7 +17,7 @@ namespace RMuseum.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@ -1295,7 +1295,8 @@ namespace RMuseum.Migrations
.HasColumnType("bit");
b.Property<string>("FullTitle")
.HasColumnType("nvarchar(max)");
.HasMaxLength(1500)
.HasColumnType("nvarchar(1500)");
b.Property<string>("FullUrl")
.HasColumnType("nvarchar(450)");
@ -1307,40 +1308,49 @@ namespace RMuseum.Migrations
.HasColumnType("nvarchar(max)");
b.Property<string>("Language")
.HasColumnType("nvarchar(max)");
.HasMaxLength(8)
.HasColumnType("nvarchar(8)");
b.Property<int>("MixedModeOrder")
.HasColumnType("int");
b.Property<string>("OldTag")
.HasColumnType("nvarchar(max)");
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.Property<string>("OldTagPageUrl")
.HasColumnType("nvarchar(max)");
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property<string>("PlainText")
.HasColumnType("nvarchar(max)");
b.Property<string>("PoemSummary")
.HasColumnType("nvarchar(max)");
.HasMaxLength(3000)
.HasColumnType("nvarchar(3000)");
b.Property<bool>("Published")
.HasColumnType("bit");
b.Property<string>("RhymeLetters")
.HasColumnType("nvarchar(max)");
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("SourceName")
.HasColumnType("nvarchar(max)");
.HasMaxLength(64)
.HasColumnType("nvarchar(64)");
b.Property<string>("SourceUrlSlug")
.HasColumnType("nvarchar(max)");
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
.HasMaxLength(1500)
.HasColumnType("nvarchar(1500)");
b.Property<string>("UrlSlug")
.HasColumnType("nvarchar(max)");
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.HasKey("Id");
@ -2267,7 +2277,8 @@ namespace RMuseum.Migrations
.HasColumnType("int");
b.Property<string>("CoupletSummary")
.HasColumnType("nvarchar(max)");
.HasMaxLength(4000)
.HasColumnType("nvarchar(4000)");
b.Property<int?>("LanguageId")
.HasColumnType("int");
@ -4465,7 +4476,7 @@ namespace RMuseum.Migrations
b.ToTable("GeneralImages");
b.HasDiscriminator<string>("Discriminator").HasValue("RImage");
b.HasDiscriminator().HasValue("RImage");
b.UseTphMappingStrategy();
});

View File

@ -4269,6 +4269,18 @@
<member name="M:RMuseum.Migrations.GeoAIFields.BuildTargetModel(Microsoft.EntityFrameworkCore.ModelBuilder)">
<inheritdoc />
</member>
<member name="T:RMuseum.Migrations.LimitedFieldLengths1">
<inheritdoc />
</member>
<member name="M:RMuseum.Migrations.LimitedFieldLengths1.Up(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)">
<inheritdoc />
</member>
<member name="M:RMuseum.Migrations.LimitedFieldLengths1.Down(Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder)">
<inheritdoc />
</member>
<member name="M:RMuseum.Migrations.LimitedFieldLengths1.BuildTargetModel(Microsoft.EntityFrameworkCore.ModelBuilder)">
<inheritdoc />
</member>
<member name="T:RMuseum.Models.Accounting.DonationExpenditure">
<summary>
donation expenditures

View File

@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@ -69,9 +70,12 @@ namespace RMuseum
providerOptions.EnableRetryOnFailure();
providerOptions.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
}
)
).ConfigureWarnings(warnings =>
warnings.Ignore(RelationalEventId.PendingModelChangesWarning))
);
//Audit.Core.Configuration.JsonSettings.ContractResolver = AuditNetEnvironmentSkippingContractResolver.Instance;
Audit.Core.Configuration.DataProvider = new RAuditDataProvider(Configuration.GetConnectionString("DefaultConnection"));
Audit.Core.Configuration.AuditDisabled = bool.Parse(Configuration["AuditNetEnabled"]) == false;