diff --git a/MSDF.DataChecker.Migrations.Postgres/MSDF.DataChecker.Migrations.Postgres.csproj b/MSDF.DataChecker.Migrations.Postgres/MSDF.DataChecker.Migrations.Postgres.csproj new file mode 100644 index 0000000..c43c789 --- /dev/null +++ b/MSDF.DataChecker.Migrations.Postgres/MSDF.DataChecker.Migrations.Postgres.csproj @@ -0,0 +1,15 @@ + + + + net7.0 + + + + + + + + + + + diff --git a/MSDF.DataChecker.Migrations.Postgres/Migrations/20230405175832_InitialCreate.Designer.cs b/MSDF.DataChecker.Migrations.Postgres/Migrations/20230405175832_InitialCreate.Designer.cs new file mode 100644 index 0000000..c0400f4 --- /dev/null +++ b/MSDF.DataChecker.Migrations.Postgres/Migrations/20230405175832_InitialCreate.Designer.cs @@ -0,0 +1,591 @@ +// +using System; +using MSDF.DataChecker.Persistence.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MSDF.DataChecker.Migrations.Postgres.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20230405175832_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Catalogs.Catalog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CatalogType") + .HasMaxLength(350) + .HasColumnType("character varying(350)"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(350) + .HasColumnType("character varying(350)"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Catalogs", "core"); + + b.HasData( + new + { + Id = 1, + CatalogType = "EnvironmentType", + Description = "Ed-Fi v2.X", + Name = "Ed-Fi v2.X", + Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + Id = 2, + CatalogType = "EnvironmentType", + Description = "Ed-Fi v3.X", + Name = "Ed-Fi v3.X", + Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + Id = 3, + CatalogType = "RuleDetailsDestinationType", + Description = "EdFiRuleExecutionLogDetails", + Name = "EdFiRuleExecutionLogDetails", + Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ContainerTypeId") + .HasColumnType("integer"); + + b.Property("CreatedByUserId") + .HasColumnType("uuid"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("EnvironmentType") + .HasColumnType("integer"); + + b.Property("IsDefault") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("ParentContainerId") + .HasColumnType("uuid"); + + b.Property("RuleDetailsDestinationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContainerTypeId"); + + b.HasIndex("ParentContainerId"); + + b.HasIndex("RuleDetailsDestinationId"); + + b.ToTable("Containers", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.ContainerType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ContainerTypes", "core"); + + b.HasData( + new + { + Id = 1, + Name = "Collection" + }, + new + { + Id = 2, + Name = "Folder" + }); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.DatabaseEnvironments.DatabaseEnvironment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DataSource") + .HasColumnType("text"); + + b.Property("Database") + .HasColumnType("text"); + + b.Property("ExtraData") + .HasColumnType("text"); + + b.Property("MapTables") + .HasColumnType("text"); + + b.Property("MaxNumberResults") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Password") + .HasColumnType("text"); + + b.Property("SecurityIntegrated") + .HasColumnType("boolean"); + + b.Property("TimeoutInMinutes") + .HasColumnType("integer"); + + b.Property("User") + .HasColumnType("text"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("DatabaseEnvironments", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Logs.Log", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("Information") + .HasColumnType("text"); + + b.Property("Source") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Logs", "core"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogDetails.EdFiRuleExecutionLogDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CourseCode") + .HasColumnType("text"); + + b.Property("Discriminator") + .HasColumnType("text"); + + b.Property("EducationOrganizationId") + .HasColumnType("integer"); + + b.Property("OtherDetails") + .HasColumnType("text"); + + b.Property("ProgramName") + .HasColumnType("text"); + + b.Property("RuleExecutionLogId") + .HasColumnType("integer"); + + b.Property("StaffUniqueId") + .HasColumnType("text"); + + b.Property("StudentUniqueId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RuleExecutionLogId"); + + b.ToTable("EdFiRuleExecutionLogDetails", "destination"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DatabaseEnvironmentId") + .HasColumnType("uuid"); + + b.Property("DetailsSchema") + .HasColumnType("text"); + + b.Property("DetailsTableName") + .HasColumnType("text"); + + b.Property("DiagnosticSql") + .HasColumnType("text"); + + b.Property("Evaluation") + .HasColumnType("boolean"); + + b.Property("ExecutedSql") + .HasColumnType("text"); + + b.Property("ExecutionDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ExecutionTimeMs") + .HasColumnType("bigint"); + + b.Property("Response") + .HasColumnType("text"); + + b.Property("Result") + .HasColumnType("integer"); + + b.Property("RuleDetailsDestinationId") + .HasColumnType("integer"); + + b.Property("RuleId") + .HasColumnType("uuid"); + + b.Property("StatusId") + .HasColumnType("integer"); + + b.Property("ValidationRunId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RuleId"); + + b.HasIndex("ValidationRunId"); + + b.ToTable("RuleExecutionLogs", "destination"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ContainerId") + .HasColumnType("uuid"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("DiagnosticSql") + .HasColumnType("text"); + + b.Property("ErrorMessage") + .HasColumnType("text"); + + b.Property("ErrorSeverityLevel") + .HasColumnType("integer"); + + b.Property("MaxNumberResults") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Resolution") + .HasColumnType("text"); + + b.Property("RuleIdentification") + .HasColumnType("text"); + + b.Property("Version") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ContainerId"); + + b.ToTable("Rules", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsPublic") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Tags", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.TagEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContainerId") + .HasColumnType("uuid"); + + b.Property("RuleId") + .HasColumnType("uuid"); + + b.Property("TagId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContainerId"); + + b.HasIndex("RuleId"); + + b.HasIndex("TagId"); + + b.ToTable("TagEntities", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.UserParams.UserParam", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DatabaseEnvironmentId") + .HasColumnType("uuid"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("DatabaseEnvironmentId"); + + b.ToTable("UserParams", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.ValidationsRun.ValidationRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("HostDatabase") + .IsRequired() + .HasColumnType("text"); + + b.Property("HostServer") + .IsRequired() + .HasColumnType("text"); + + b.Property("RunStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("Source") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("ValidationRun", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.ContainerType", "ContainerType") + .WithMany() + .HasForeignKey("ContainerTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", "ParentContainer") + .WithMany("ChildContainers") + .HasForeignKey("ParentContainerId"); + + b.HasOne("MSDF.DataChecker.Persistence.Catalogs.Catalog", "RuleDetailsDestination") + .WithMany() + .HasForeignKey("RuleDetailsDestinationId"); + + b.Navigation("ContainerType"); + + b.Navigation("ParentContainer"); + + b.Navigation("RuleDetailsDestination"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogDetails.EdFiRuleExecutionLogDetail", b => + { + b.HasOne("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", "RuleExecutionLog") + .WithMany() + .HasForeignKey("RuleExecutionLogId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RuleExecutionLog"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Rules.Rule", null) + .WithMany("RuleExecutionLogs") + .HasForeignKey("RuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MSDF.DataChecker.Persistence.ValidationsRun.ValidationRun", "ValidationRun") + .WithMany() + .HasForeignKey("ValidationRunId"); + + b.Navigation("ValidationRun"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", null) + .WithMany("Rules") + .HasForeignKey("ContainerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.TagEntity", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", "Container") + .WithMany() + .HasForeignKey("ContainerId"); + + b.HasOne("MSDF.DataChecker.Persistence.Rules.Rule", "Rule") + .WithMany() + .HasForeignKey("RuleId"); + + b.HasOne("MSDF.DataChecker.Persistence.Tags.Tag", "Tag") + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Container"); + + b.Navigation("Rule"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.UserParams.UserParam", b => + { + b.HasOne("MSDF.DataChecker.Persistence.DatabaseEnvironments.DatabaseEnvironment", null) + .WithMany("UserParams") + .HasForeignKey("DatabaseEnvironmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => + { + b.Navigation("ChildContainers"); + + b.Navigation("Rules"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.DatabaseEnvironments.DatabaseEnvironment", b => + { + b.Navigation("UserParams"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => + { + b.Navigation("RuleExecutionLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MSDF.DataChecker.Migrations.Postgres/Migrations/20230405175832_InitialCreate.cs b/MSDF.DataChecker.Migrations.Postgres/Migrations/20230405175832_InitialCreate.cs new file mode 100644 index 0000000..b827e8a --- /dev/null +++ b/MSDF.DataChecker.Migrations.Postgres/Migrations/20230405175832_InitialCreate.cs @@ -0,0 +1,470 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace MSDF.DataChecker.Migrations.Postgres.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "core"); + + migrationBuilder.EnsureSchema( + name: "datachecker"); + + migrationBuilder.EnsureSchema( + name: "destination"); + + migrationBuilder.CreateTable( + name: "Catalogs", + schema: "core", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CatalogType = table.Column(type: "character varying(350)", maxLength: 350, nullable: true), + Name = table.Column(type: "character varying(350)", maxLength: 350, nullable: true), + Description = table.Column(type: "text", nullable: true), + Updated = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Catalogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ContainerTypes", + schema: "core", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: true), + Description = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ContainerTypes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "DatabaseEnvironments", + schema: "datachecker", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: true), + Version = table.Column(type: "integer", nullable: false), + Database = table.Column(type: "text", nullable: true), + User = table.Column(type: "text", nullable: true), + Password = table.Column(type: "text", nullable: true), + DataSource = table.Column(type: "text", nullable: true), + ExtraData = table.Column(type: "text", nullable: true), + MapTables = table.Column(type: "text", nullable: true), + CreatedDate = table.Column(type: "timestamp with time zone", nullable: false), + SecurityIntegrated = table.Column(type: "boolean", nullable: true), + MaxNumberResults = table.Column(type: "integer", nullable: true), + TimeoutInMinutes = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_DatabaseEnvironments", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Logs", + schema: "core", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Information = table.Column(type: "text", nullable: true), + Source = table.Column(type: "text", nullable: true), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Logs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Tags", + schema: "datachecker", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: true), + Description = table.Column(type: "text", nullable: true), + IsPublic = table.Column(type: "boolean", nullable: false), + Created = table.Column(type: "timestamp with time zone", nullable: false), + Updated = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Tags", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ValidationRun", + schema: "datachecker", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RunStatus = table.Column(type: "text", nullable: false), + HostServer = table.Column(type: "text", nullable: false), + HostDatabase = table.Column(type: "text", nullable: false), + Source = table.Column(type: "text", nullable: false), + StartTime = table.Column(type: "timestamp with time zone", nullable: false), + EndTime = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ValidationRun", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Containers", + schema: "datachecker", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: true), + ContainerTypeId = table.Column(type: "integer", nullable: false), + CreatedByUserId = table.Column(type: "uuid", nullable: true), + ParentContainerId = table.Column(type: "uuid", nullable: true), + IsDefault = table.Column(type: "boolean", nullable: false), + Description = table.Column(type: "text", nullable: true), + EnvironmentType = table.Column(type: "integer", nullable: false), + RuleDetailsDestinationId = table.Column(type: "integer", nullable: true), + DateUpdated = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Containers", x => x.Id); + table.ForeignKey( + name: "FK_Containers_Catalogs_RuleDetailsDestinationId", + column: x => x.RuleDetailsDestinationId, + principalSchema: "core", + principalTable: "Catalogs", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Containers_ContainerTypes_ContainerTypeId", + column: x => x.ContainerTypeId, + principalSchema: "core", + principalTable: "ContainerTypes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Containers_Containers_ParentContainerId", + column: x => x.ParentContainerId, + principalSchema: "datachecker", + principalTable: "Containers", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "UserParams", + schema: "datachecker", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: true), + Value = table.Column(type: "text", nullable: true), + DatabaseEnvironmentId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UserParams", x => x.Id); + table.ForeignKey( + name: "FK_UserParams_DatabaseEnvironments_DatabaseEnvironmentId", + column: x => x.DatabaseEnvironmentId, + principalSchema: "datachecker", + principalTable: "DatabaseEnvironments", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Rules", + schema: "datachecker", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + ContainerId = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: true), + Description = table.Column(type: "text", nullable: true), + ErrorMessage = table.Column(type: "text", nullable: true), + ErrorSeverityLevel = table.Column(type: "integer", nullable: false), + Resolution = table.Column(type: "text", nullable: true), + DiagnosticSql = table.Column(type: "text", nullable: true), + Version = table.Column(type: "text", nullable: true), + RuleIdentification = table.Column(type: "text", nullable: true), + MaxNumberResults = table.Column(type: "integer", nullable: true), + DateUpdated = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Rules", x => x.Id); + table.ForeignKey( + name: "FK_Rules_Containers_ContainerId", + column: x => x.ContainerId, + principalSchema: "datachecker", + principalTable: "Containers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RuleExecutionLogs", + schema: "destination", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RuleId = table.Column(type: "uuid", nullable: false), + DatabaseEnvironmentId = table.Column(type: "uuid", nullable: false), + Response = table.Column(type: "text", nullable: true), + Result = table.Column(type: "integer", nullable: false), + Evaluation = table.Column(type: "boolean", nullable: false), + StatusId = table.Column(type: "integer", nullable: false), + ExecutionDate = table.Column(type: "timestamp with time zone", nullable: false), + ExecutionTimeMs = table.Column(type: "bigint", nullable: false), + ExecutedSql = table.Column(type: "text", nullable: true), + DiagnosticSql = table.Column(type: "text", nullable: true), + RuleDetailsDestinationId = table.Column(type: "integer", nullable: true), + DetailsSchema = table.Column(type: "text", nullable: true), + DetailsTableName = table.Column(type: "text", nullable: true), + ValidationRunId = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_RuleExecutionLogs", x => x.Id); + table.ForeignKey( + name: "FK_RuleExecutionLogs_Rules_RuleId", + column: x => x.RuleId, + principalSchema: "datachecker", + principalTable: "Rules", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RuleExecutionLogs_ValidationRun_ValidationRunId", + column: x => x.ValidationRunId, + principalSchema: "datachecker", + principalTable: "ValidationRun", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "TagEntities", + schema: "datachecker", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TagId = table.Column(type: "integer", nullable: false), + ContainerId = table.Column(type: "uuid", nullable: true), + RuleId = table.Column(type: "uuid", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TagEntities", x => x.Id); + table.ForeignKey( + name: "FK_TagEntities_Containers_ContainerId", + column: x => x.ContainerId, + principalSchema: "datachecker", + principalTable: "Containers", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_TagEntities_Rules_RuleId", + column: x => x.RuleId, + principalSchema: "datachecker", + principalTable: "Rules", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_TagEntities_Tags_TagId", + column: x => x.TagId, + principalSchema: "datachecker", + principalTable: "Tags", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "EdFiRuleExecutionLogDetails", + schema: "destination", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + EducationOrganizationId = table.Column(type: "integer", nullable: true), + StudentUniqueId = table.Column(type: "text", nullable: true), + CourseCode = table.Column(type: "text", nullable: true), + Discriminator = table.Column(type: "text", nullable: true), + ProgramName = table.Column(type: "text", nullable: true), + StaffUniqueId = table.Column(type: "text", nullable: true), + OtherDetails = table.Column(type: "text", nullable: true), + RuleExecutionLogId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EdFiRuleExecutionLogDetails", x => x.Id); + table.ForeignKey( + name: "FK_EdFiRuleExecutionLogDetails_RuleExecutionLogs_RuleExecution~", + column: x => x.RuleExecutionLogId, + principalSchema: "destination", + principalTable: "RuleExecutionLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + schema: "core", + table: "Catalogs", + columns: new[] { "Id", "CatalogType", "Description", "Name", "Updated" }, + values: new object[,] + { + { 1, "EnvironmentType", "Ed-Fi v2.X", "Ed-Fi v2.X", new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }, + { 2, "EnvironmentType", "Ed-Fi v3.X", "Ed-Fi v3.X", new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }, + { 3, "RuleDetailsDestinationType", "EdFiRuleExecutionLogDetails", "EdFiRuleExecutionLogDetails", new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) } + }); + + migrationBuilder.InsertData( + schema: "core", + table: "ContainerTypes", + columns: new[] { "Id", "Description", "Name" }, + values: new object[,] + { + { 1, null, "Collection" }, + { 2, null, "Folder" } + }); + + migrationBuilder.CreateIndex( + name: "IX_Containers_ContainerTypeId", + schema: "datachecker", + table: "Containers", + column: "ContainerTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_Containers_ParentContainerId", + schema: "datachecker", + table: "Containers", + column: "ParentContainerId"); + + migrationBuilder.CreateIndex( + name: "IX_Containers_RuleDetailsDestinationId", + schema: "datachecker", + table: "Containers", + column: "RuleDetailsDestinationId"); + + migrationBuilder.CreateIndex( + name: "IX_EdFiRuleExecutionLogDetails_RuleExecutionLogId", + schema: "destination", + table: "EdFiRuleExecutionLogDetails", + column: "RuleExecutionLogId"); + + migrationBuilder.CreateIndex( + name: "IX_RuleExecutionLogs_RuleId", + schema: "destination", + table: "RuleExecutionLogs", + column: "RuleId"); + + migrationBuilder.CreateIndex( + name: "IX_RuleExecutionLogs_ValidationRunId", + schema: "destination", + table: "RuleExecutionLogs", + column: "ValidationRunId"); + + migrationBuilder.CreateIndex( + name: "IX_Rules_ContainerId", + schema: "datachecker", + table: "Rules", + column: "ContainerId"); + + migrationBuilder.CreateIndex( + name: "IX_TagEntities_ContainerId", + schema: "datachecker", + table: "TagEntities", + column: "ContainerId"); + + migrationBuilder.CreateIndex( + name: "IX_TagEntities_RuleId", + schema: "datachecker", + table: "TagEntities", + column: "RuleId"); + + migrationBuilder.CreateIndex( + name: "IX_TagEntities_TagId", + schema: "datachecker", + table: "TagEntities", + column: "TagId"); + + migrationBuilder.CreateIndex( + name: "IX_UserParams_DatabaseEnvironmentId", + schema: "datachecker", + table: "UserParams", + column: "DatabaseEnvironmentId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "EdFiRuleExecutionLogDetails", + schema: "destination"); + + migrationBuilder.DropTable( + name: "Logs", + schema: "core"); + + migrationBuilder.DropTable( + name: "TagEntities", + schema: "datachecker"); + + migrationBuilder.DropTable( + name: "UserParams", + schema: "datachecker"); + + migrationBuilder.DropTable( + name: "RuleExecutionLogs", + schema: "destination"); + + migrationBuilder.DropTable( + name: "Tags", + schema: "datachecker"); + + migrationBuilder.DropTable( + name: "DatabaseEnvironments", + schema: "datachecker"); + + migrationBuilder.DropTable( + name: "Rules", + schema: "datachecker"); + + migrationBuilder.DropTable( + name: "ValidationRun", + schema: "datachecker"); + + migrationBuilder.DropTable( + name: "Containers", + schema: "datachecker"); + + migrationBuilder.DropTable( + name: "Catalogs", + schema: "core"); + + migrationBuilder.DropTable( + name: "ContainerTypes", + schema: "core"); + } + } +} diff --git a/MSDF.DataChecker.Migrations.Postgres/Migrations/DatabaseContextModelSnapshot.cs b/MSDF.DataChecker.Migrations.Postgres/Migrations/DatabaseContextModelSnapshot.cs new file mode 100644 index 0000000..46b722e --- /dev/null +++ b/MSDF.DataChecker.Migrations.Postgres/Migrations/DatabaseContextModelSnapshot.cs @@ -0,0 +1,588 @@ +// +using System; +using MSDF.DataChecker.Persistence.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace MSDF.DataChecker.Migrations.Postgres.Migrations +{ + [DbContext(typeof(DatabaseContext))] + partial class DatabaseContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Catalogs.Catalog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CatalogType") + .HasMaxLength(350) + .HasColumnType("character varying(350)"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(350) + .HasColumnType("character varying(350)"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Catalogs", "core"); + + b.HasData( + new + { + Id = 1, + CatalogType = "EnvironmentType", + Description = "Ed-Fi v2.X", + Name = "Ed-Fi v2.X", + Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + Id = 2, + CatalogType = "EnvironmentType", + Description = "Ed-Fi v3.X", + Name = "Ed-Fi v3.X", + Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + Id = 3, + CatalogType = "RuleDetailsDestinationType", + Description = "EdFiRuleExecutionLogDetails", + Name = "EdFiRuleExecutionLogDetails", + Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ContainerTypeId") + .HasColumnType("integer"); + + b.Property("CreatedByUserId") + .HasColumnType("uuid"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("EnvironmentType") + .HasColumnType("integer"); + + b.Property("IsDefault") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("ParentContainerId") + .HasColumnType("uuid"); + + b.Property("RuleDetailsDestinationId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContainerTypeId"); + + b.HasIndex("ParentContainerId"); + + b.HasIndex("RuleDetailsDestinationId"); + + b.ToTable("Containers", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.ContainerType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ContainerTypes", "core"); + + b.HasData( + new + { + Id = 1, + Name = "Collection" + }, + new + { + Id = 2, + Name = "Folder" + }); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.DatabaseEnvironments.DatabaseEnvironment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("DataSource") + .HasColumnType("text"); + + b.Property("Database") + .HasColumnType("text"); + + b.Property("ExtraData") + .HasColumnType("text"); + + b.Property("MapTables") + .HasColumnType("text"); + + b.Property("MaxNumberResults") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Password") + .HasColumnType("text"); + + b.Property("SecurityIntegrated") + .HasColumnType("boolean"); + + b.Property("TimeoutInMinutes") + .HasColumnType("integer"); + + b.Property("User") + .HasColumnType("text"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("DatabaseEnvironments", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Logs.Log", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("Information") + .HasColumnType("text"); + + b.Property("Source") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Logs", "core"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogDetails.EdFiRuleExecutionLogDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CourseCode") + .HasColumnType("text"); + + b.Property("Discriminator") + .HasColumnType("text"); + + b.Property("EducationOrganizationId") + .HasColumnType("integer"); + + b.Property("OtherDetails") + .HasColumnType("text"); + + b.Property("ProgramName") + .HasColumnType("text"); + + b.Property("RuleExecutionLogId") + .HasColumnType("integer"); + + b.Property("StaffUniqueId") + .HasColumnType("text"); + + b.Property("StudentUniqueId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RuleExecutionLogId"); + + b.ToTable("EdFiRuleExecutionLogDetails", "destination"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DatabaseEnvironmentId") + .HasColumnType("uuid"); + + b.Property("DetailsSchema") + .HasColumnType("text"); + + b.Property("DetailsTableName") + .HasColumnType("text"); + + b.Property("DiagnosticSql") + .HasColumnType("text"); + + b.Property("Evaluation") + .HasColumnType("boolean"); + + b.Property("ExecutedSql") + .HasColumnType("text"); + + b.Property("ExecutionDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ExecutionTimeMs") + .HasColumnType("bigint"); + + b.Property("Response") + .HasColumnType("text"); + + b.Property("Result") + .HasColumnType("integer"); + + b.Property("RuleDetailsDestinationId") + .HasColumnType("integer"); + + b.Property("RuleId") + .HasColumnType("uuid"); + + b.Property("StatusId") + .HasColumnType("integer"); + + b.Property("ValidationRunId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("RuleId"); + + b.HasIndex("ValidationRunId"); + + b.ToTable("RuleExecutionLogs", "destination"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ContainerId") + .HasColumnType("uuid"); + + b.Property("DateUpdated") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("DiagnosticSql") + .HasColumnType("text"); + + b.Property("ErrorMessage") + .HasColumnType("text"); + + b.Property("ErrorSeverityLevel") + .HasColumnType("integer"); + + b.Property("MaxNumberResults") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Resolution") + .HasColumnType("text"); + + b.Property("RuleIdentification") + .HasColumnType("text"); + + b.Property("Version") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ContainerId"); + + b.ToTable("Rules", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("IsPublic") + .HasColumnType("boolean"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Updated") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Tags", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.TagEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContainerId") + .HasColumnType("uuid"); + + b.Property("RuleId") + .HasColumnType("uuid"); + + b.Property("TagId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContainerId"); + + b.HasIndex("RuleId"); + + b.HasIndex("TagId"); + + b.ToTable("TagEntities", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.UserParams.UserParam", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DatabaseEnvironmentId") + .HasColumnType("uuid"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("DatabaseEnvironmentId"); + + b.ToTable("UserParams", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.ValidationsRun.ValidationRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("HostDatabase") + .IsRequired() + .HasColumnType("text"); + + b.Property("HostServer") + .IsRequired() + .HasColumnType("text"); + + b.Property("RunStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("Source") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("ValidationRun", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.ContainerType", "ContainerType") + .WithMany() + .HasForeignKey("ContainerTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", "ParentContainer") + .WithMany("ChildContainers") + .HasForeignKey("ParentContainerId"); + + b.HasOne("MSDF.DataChecker.Persistence.Catalogs.Catalog", "RuleDetailsDestination") + .WithMany() + .HasForeignKey("RuleDetailsDestinationId"); + + b.Navigation("ContainerType"); + + b.Navigation("ParentContainer"); + + b.Navigation("RuleDetailsDestination"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogDetails.EdFiRuleExecutionLogDetail", b => + { + b.HasOne("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", "RuleExecutionLog") + .WithMany() + .HasForeignKey("RuleExecutionLogId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RuleExecutionLog"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Rules.Rule", null) + .WithMany("RuleExecutionLogs") + .HasForeignKey("RuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MSDF.DataChecker.Persistence.ValidationsRun.ValidationRun", "ValidationRun") + .WithMany() + .HasForeignKey("ValidationRunId"); + + b.Navigation("ValidationRun"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", null) + .WithMany("Rules") + .HasForeignKey("ContainerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.TagEntity", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", "Container") + .WithMany() + .HasForeignKey("ContainerId"); + + b.HasOne("MSDF.DataChecker.Persistence.Rules.Rule", "Rule") + .WithMany() + .HasForeignKey("RuleId"); + + b.HasOne("MSDF.DataChecker.Persistence.Tags.Tag", "Tag") + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Container"); + + b.Navigation("Rule"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.UserParams.UserParam", b => + { + b.HasOne("MSDF.DataChecker.Persistence.DatabaseEnvironments.DatabaseEnvironment", null) + .WithMany("UserParams") + .HasForeignKey("DatabaseEnvironmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => + { + b.Navigation("ChildContainers"); + + b.Navigation("Rules"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.DatabaseEnvironments.DatabaseEnvironment", b => + { + b.Navigation("UserParams"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => + { + b.Navigation("RuleExecutionLogs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MSDF.DataChecker.Migrations.SqlServer/MSDF.DataChecker.Migrations.SqlServer.csproj b/MSDF.DataChecker.Migrations.SqlServer/MSDF.DataChecker.Migrations.SqlServer.csproj new file mode 100644 index 0000000..6968fca --- /dev/null +++ b/MSDF.DataChecker.Migrations.SqlServer/MSDF.DataChecker.Migrations.SqlServer.csproj @@ -0,0 +1,11 @@ + + + + net7.0 + + + + + + + diff --git a/MSDF.DataChecker.Persistence/Migrations/20200115132900_InitialCreate.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200115132900_InitialCreate.Designer.cs similarity index 99% rename from MSDF.DataChecker.Persistence/Migrations/20200115132900_InitialCreate.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200115132900_InitialCreate.Designer.cs index ff21d55..f656680 100644 --- a/MSDF.DataChecker.Persistence/Migrations/20200115132900_InitialCreate.Designer.cs +++ b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200115132900_InitialCreate.Designer.cs @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: Apache-2.0 // Licensed to the Ed-Fi Alliance under one or more agreements. // The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. // See the LICENSE and NOTICES files in the project root for more information. @@ -11,7 +11,7 @@ using MSDF.DataChecker.Persistence.EntityFramework; using System; -namespace MSDF.DataChecker.Persistence.Migrations +namespace MSDF.DataChecker.Migrations.SqlServer.Migrations { [DbContext(typeof(DatabaseContext))] [Migration("20200115132900_InitialCreate")] diff --git a/MSDF.DataChecker.Persistence/Migrations/20200115132900_InitialCreate.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200115132900_InitialCreate.cs similarity index 99% rename from MSDF.DataChecker.Persistence/Migrations/20200115132900_InitialCreate.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200115132900_InitialCreate.cs index 4c248d1..4ac591d 100644 --- a/MSDF.DataChecker.Persistence/Migrations/20200115132900_InitialCreate.cs +++ b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200115132900_InitialCreate.cs @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: Apache-2.0 // Licensed to the Ed-Fi Alliance under one or more agreements. // The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. // See the LICENSE and NOTICES files in the project root for more information. @@ -6,7 +6,7 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; -namespace MSDF.DataChecker.Persistence.Migrations +namespace MSDF.DataChecker.Migrations.SqlServer.Migrations { public partial class InitialCreate : Migration { diff --git a/MSDF.DataChecker.Persistence/Migrations/20200213225557_RuleExecutionLogDiagnosticSql.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200213225557_RuleExecutionLogDiagnosticSql.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200213225557_RuleExecutionLogDiagnosticSql.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200213225557_RuleExecutionLogDiagnosticSql.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200213225557_RuleExecutionLogDiagnosticSql.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200213225557_RuleExecutionLogDiagnosticSql.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200213225557_RuleExecutionLogDiagnosticSql.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200213225557_RuleExecutionLogDiagnosticSql.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200424161909_RuleIdentification.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200424161909_RuleIdentification.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200424161909_RuleIdentification.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200424161909_RuleIdentification.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200424161909_RuleIdentification.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200424161909_RuleIdentification.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200424161909_RuleIdentification.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200424161909_RuleIdentification.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200426230135_SecurityIntegratedEnvironment.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200426230135_SecurityIntegratedEnvironment.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200426230135_SecurityIntegratedEnvironment.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200426230135_SecurityIntegratedEnvironment.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200426230135_SecurityIntegratedEnvironment.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200426230135_SecurityIntegratedEnvironment.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200426230135_SecurityIntegratedEnvironment.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200426230135_SecurityIntegratedEnvironment.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200526174618_Logs.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200526174618_Logs.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200526174618_Logs.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200526174618_Logs.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200526174618_Logs.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200526174618_Logs.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200526174618_Logs.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200526174618_Logs.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200527212023_UpdateRuleIdentification.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200527212023_UpdateRuleIdentification.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200527212023_UpdateRuleIdentification.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200527212023_UpdateRuleIdentification.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200527212023_UpdateRuleIdentification.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200527212023_UpdateRuleIdentification.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200527212023_UpdateRuleIdentification.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200527212023_UpdateRuleIdentification.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200601204250_EdFiVersionCollection.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200601204250_EdFiVersionCollection.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200601204250_EdFiVersionCollection.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200601204250_EdFiVersionCollection.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200601204250_EdFiVersionCollection.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200601204250_EdFiVersionCollection.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200601204250_EdFiVersionCollection.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200601204250_EdFiVersionCollection.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200601225028_Catalogs.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200601225028_Catalogs.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200601225028_Catalogs.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200601225028_Catalogs.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200601225028_Catalogs.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200601225028_Catalogs.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200601225028_Catalogs.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200601225028_Catalogs.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200604232847_Tags.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200604232847_Tags.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200604232847_Tags.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200604232847_Tags.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200604232847_Tags.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200604232847_Tags.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200604232847_Tags.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200604232847_Tags.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200609174215_EdFiRuleExecutionLogDetails.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200609174215_EdFiRuleExecutionLogDetails.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200609174215_EdFiRuleExecutionLogDetails.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200609174215_EdFiRuleExecutionLogDetails.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200609174215_EdFiRuleExecutionLogDetails.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200609174215_EdFiRuleExecutionLogDetails.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200609174215_EdFiRuleExecutionLogDetails.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200609174215_EdFiRuleExecutionLogDetails.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200610180409_RuleDetailsDestination.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200610180409_RuleDetailsDestination.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200610180409_RuleDetailsDestination.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200610180409_RuleDetailsDestination.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200610180409_RuleDetailsDestination.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200610180409_RuleDetailsDestination.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200610180409_RuleDetailsDestination.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200610180409_RuleDetailsDestination.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200619002702_AddingRuleDetailsDestinationId.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200619002702_AddingRuleDetailsDestinationId.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200619002702_AddingRuleDetailsDestinationId.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200619002702_AddingRuleDetailsDestinationId.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200619002702_AddingRuleDetailsDestinationId.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200619002702_AddingRuleDetailsDestinationId.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200619002702_AddingRuleDetailsDestinationId.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200619002702_AddingRuleDetailsDestinationId.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200623233009_RemovingRuleCountFields.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200623233009_RemovingRuleCountFields.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200623233009_RemovingRuleCountFields.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200623233009_RemovingRuleCountFields.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200623233009_RemovingRuleCountFields.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200623233009_RemovingRuleCountFields.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200623233009_RemovingRuleCountFields.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200623233009_RemovingRuleCountFields.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200625221428_AddingFieldsForExport.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200625221428_AddingFieldsForExport.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200625221428_AddingFieldsForExport.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200625221428_AddingFieldsForExport.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200625221428_AddingFieldsForExport.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200625221428_AddingFieldsForExport.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200625221428_AddingFieldsForExport.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200625221428_AddingFieldsForExport.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200703224157_RemoveRuleIdentificationConstraint.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200703224157_RemoveRuleIdentificationConstraint.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200703224157_RemoveRuleIdentificationConstraint.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200703224157_RemoveRuleIdentificationConstraint.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200703224157_RemoveRuleIdentificationConstraint.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200703224157_RemoveRuleIdentificationConstraint.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200703224157_RemoveRuleIdentificationConstraint.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200703224157_RemoveRuleIdentificationConstraint.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200713201853_MaxNumberResults.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200713201853_MaxNumberResults.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200713201853_MaxNumberResults.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200713201853_MaxNumberResults.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200713201853_MaxNumberResults.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200713201853_MaxNumberResults.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200713201853_MaxNumberResults.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200713201853_MaxNumberResults.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200721140335_SchemaChanges.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200721140335_SchemaChanges.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200721140335_SchemaChanges.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200721140335_SchemaChanges.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200721140335_SchemaChanges.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200721140335_SchemaChanges.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200721140335_SchemaChanges.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200721140335_SchemaChanges.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200727214901_RuleExecutionLogsNewSchema.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200727214901_RuleExecutionLogsNewSchema.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200727214901_RuleExecutionLogsNewSchema.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200727214901_RuleExecutionLogsNewSchema.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200727214901_RuleExecutionLogsNewSchema.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200727214901_RuleExecutionLogsNewSchema.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200727214901_RuleExecutionLogsNewSchema.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200727214901_RuleExecutionLogsNewSchema.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200803164434_ChangeRulesDestinationTableToCollection.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200803164434_ChangeRulesDestinationTableToCollection.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200803164434_ChangeRulesDestinationTableToCollection.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200803164434_ChangeRulesDestinationTableToCollection.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200803164434_ChangeRulesDestinationTableToCollection.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200803164434_ChangeRulesDestinationTableToCollection.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200803164434_ChangeRulesDestinationTableToCollection.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200803164434_ChangeRulesDestinationTableToCollection.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200812033141_UpdateModelToSharing_1.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200812033141_UpdateModelToSharing_1.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200812033141_UpdateModelToSharing_1.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200812033141_UpdateModelToSharing_1.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200812033141_UpdateModelToSharing_1.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200812033141_UpdateModelToSharing_1.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200812033141_UpdateModelToSharing_1.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200812033141_UpdateModelToSharing_1.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200921160608_EdOrgIdSetNullableRuleDetails.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200921160608_EdOrgIdSetNullableRuleDetails.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200921160608_EdOrgIdSetNullableRuleDetails.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200921160608_EdOrgIdSetNullableRuleDetails.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20200921160608_EdOrgIdSetNullableRuleDetails.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20200921160608_EdOrgIdSetNullableRuleDetails.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20200921160608_EdOrgIdSetNullableRuleDetails.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20200921160608_EdOrgIdSetNullableRuleDetails.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20201008235330_AddingTimeoutToEnviroment.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20201008235330_AddingTimeoutToEnviroment.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20201008235330_AddingTimeoutToEnviroment.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20201008235330_AddingTimeoutToEnviroment.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20201008235330_AddingTimeoutToEnviroment.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20201008235330_AddingTimeoutToEnviroment.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20201008235330_AddingTimeoutToEnviroment.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20201008235330_AddingTimeoutToEnviroment.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20211009004812_AddUpdateDateToObjects.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20211009004812_AddUpdateDateToObjects.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20211009004812_AddUpdateDateToObjects.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20211009004812_AddUpdateDateToObjects.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20211009004812_AddUpdateDateToObjects.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20211009004812_AddUpdateDateToObjects.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20211009004812_AddUpdateDateToObjects.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20211009004812_AddUpdateDateToObjects.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20211009010401_UpdateCatalogsColumnsAndConstraint.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20211009010401_UpdateCatalogsColumnsAndConstraint.Designer.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20211009010401_UpdateCatalogsColumnsAndConstraint.Designer.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20211009010401_UpdateCatalogsColumnsAndConstraint.Designer.cs diff --git a/MSDF.DataChecker.Persistence/Migrations/20211009010401_UpdateCatalogsColumnsAndConstraint.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20211009010401_UpdateCatalogsColumnsAndConstraint.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/20211009010401_UpdateCatalogsColumnsAndConstraint.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/20211009010401_UpdateCatalogsColumnsAndConstraint.cs diff --git a/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230126185814_ValidationRunTrackingTable.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230126185814_ValidationRunTrackingTable.Designer.cs new file mode 100644 index 0000000..a25dd22 --- /dev/null +++ b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230126185814_ValidationRunTrackingTable.Designer.cs @@ -0,0 +1,523 @@ +// +using System; +using MSDF.DataChecker.Persistence.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace MSDF.DataChecker.Persistence.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20230126185814_ValidationRunTrackingTable")] + partial class ValidationRunTrackingTable + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Catalogs.Catalog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CatalogType") + .HasColumnType("nvarchar(350)") + .HasMaxLength(350); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(350)") + .HasMaxLength(350); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Catalogs","core"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContainerTypeId") + .HasColumnType("int"); + + b.Property("CreatedByUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateUpdated") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EnvironmentType") + .HasColumnType("int"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("ParentContainerId") + .HasColumnType("uniqueidentifier"); + + b.Property("RuleDetailsDestinationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ContainerTypeId"); + + b.HasIndex("ParentContainerId"); + + b.HasIndex("RuleDetailsDestinationId"); + + b.ToTable("Containers","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.ContainerType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ContainerTypes","core"); + + b.HasData( + new + { + Id = 1, + Name = "Collection" + }, + new + { + Id = 2, + Name = "Folder" + }); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.DatabaseEnvironments.DatabaseEnvironment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("DataSource") + .HasColumnType("nvarchar(max)"); + + b.Property("Database") + .HasColumnType("nvarchar(max)"); + + b.Property("ExtraData") + .HasColumnType("nvarchar(max)"); + + b.Property("MapTables") + .HasColumnType("nvarchar(max)"); + + b.Property("MaxNumberResults") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("SecurityIntegrated") + .HasColumnType("bit"); + + b.Property("TimeoutInMinutes") + .HasColumnType("int"); + + b.Property("User") + .HasColumnType("nvarchar(max)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("DatabaseEnvironments","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Logs.Log", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateCreated") + .HasColumnType("datetime2"); + + b.Property("Information") + .HasColumnType("nvarchar(max)"); + + b.Property("Source") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Logs","core"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogDetails.EdFiRuleExecutionLogDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CourseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Discriminator") + .HasColumnType("nvarchar(max)"); + + b.Property("EducationOrganizationId") + .HasColumnType("int"); + + b.Property("OtherDetails") + .HasColumnType("nvarchar(max)"); + + b.Property("ProgramName") + .HasColumnType("nvarchar(max)"); + + b.Property("RuleExecutionLogId") + .HasColumnType("int"); + + b.Property("StaffUniqueId") + .HasColumnType("nvarchar(max)"); + + b.Property("StudentUniqueId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RuleExecutionLogId"); + + b.ToTable("EdFiRuleExecutionLogDetails","destination"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DatabaseEnvironmentId") + .HasColumnType("uniqueidentifier"); + + b.Property("DetailsSchema") + .HasColumnType("nvarchar(max)"); + + b.Property("DetailsTableName") + .HasColumnType("nvarchar(max)"); + + b.Property("DiagnosticSql") + .HasColumnType("nvarchar(max)"); + + b.Property("Evaluation") + .HasColumnType("bit"); + + b.Property("ExecutedSql") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionDate") + .HasColumnType("datetime2"); + + b.Property("ExecutionTimeMs") + .HasColumnType("bigint"); + + b.Property("Response") + .HasColumnType("nvarchar(max)"); + + b.Property("Result") + .HasColumnType("int"); + + b.Property("RuleDetailsDestinationId") + .HasColumnType("int"); + + b.Property("RuleId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatusId") + .HasColumnType("int"); + + b.Property("ValidationRunId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RuleId"); + + b.HasIndex("ValidationRunId"); + + b.ToTable("RuleExecutionLogs","destination"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContainerId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateUpdated") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DiagnosticSql") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorSeverityLevel") + .HasColumnType("int"); + + b.Property("MaxNumberResults") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Resolution") + .HasColumnType("nvarchar(max)"); + + b.Property("RuleIdentification") + .HasColumnType("nvarchar(max)"); + + b.Property("Version") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ContainerId"); + + b.ToTable("Rules","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Tags","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.TagEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("ContainerId") + .HasColumnType("uniqueidentifier"); + + b.Property("RuleId") + .HasColumnType("uniqueidentifier"); + + b.Property("TagId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ContainerId"); + + b.HasIndex("RuleId"); + + b.HasIndex("TagId"); + + b.ToTable("TagEntities","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.UserParams.UserParam", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DatabaseEnvironmentId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("DatabaseEnvironmentId"); + + b.ToTable("UserParams","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.ValidationsRun.ValidationRun", b => + { + + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("EndTime") + .HasColumnType("datetime2"); + + b.Property("HostDatabase") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HostServer") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RunStatus") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Source") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StartTime") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("ValidationRun", "datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.ContainerType", "ContainerType") + .WithMany() + .HasForeignKey("ContainerTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", "ParentContainer") + .WithMany("ChildContainers") + .HasForeignKey("ParentContainerId"); + + b.HasOne("MSDF.DataChecker.Persistence.Catalogs.Catalog", "RuleDetailsDestination") + .WithMany() + .HasForeignKey("RuleDetailsDestinationId"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogDetails.EdFiRuleExecutionLogDetail", b => + { + b.HasOne("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", "RuleExecutionLog") + .WithMany() + .HasForeignKey("RuleExecutionLogId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Rules.Rule", null) + .WithMany("RuleExecutionLogs") + .HasForeignKey("RuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MSDF.DataChecker.Persistence.ValidationsRun.ValidationRun", "ValidationRun") + .WithMany() + .HasForeignKey("ValidationRunId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", null) + .WithMany("Rules") + .HasForeignKey("ContainerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.TagEntity", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", "Container") + .WithMany() + .HasForeignKey("ContainerId"); + + b.HasOne("MSDF.DataChecker.Persistence.Rules.Rule", "Rule") + .WithMany() + .HasForeignKey("RuleId"); + + b.HasOne("MSDF.DataChecker.Persistence.Tags.Tag", "Tag") + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.UserParams.UserParam", b => + { + b.HasOne("MSDF.DataChecker.Persistence.DatabaseEnvironments.DatabaseEnvironment", null) + .WithMany("UserParams") + .HasForeignKey("DatabaseEnvironmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230126185814_ValidationRunTrackingTable.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230126185814_ValidationRunTrackingTable.cs new file mode 100644 index 0000000..d1b57b7 --- /dev/null +++ b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230126185814_ValidationRunTrackingTable.cs @@ -0,0 +1,75 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace MSDF.DataChecker.Persistence.Migrations +{ + public partial class ValidationRunTrackingTable : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ValidationRunId", + schema: "destination", + table: "RuleExecutionLogs", + nullable: true, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "ValidationRun", + schema: "datachecker", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RunStatus = table.Column(nullable: false), + HostServer = table.Column(nullable: false), + HostDatabase = table.Column(nullable: false), + Source = table.Column(nullable: false), + StartTime = table.Column(nullable: false), + EndTime = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ValidationRun", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_RuleExecutionLogs_ValidationRunId", + schema: "destination", + table: "RuleExecutionLogs", + column: "ValidationRunId"); + + migrationBuilder.AddForeignKey( + name: "FK_RuleExecutionLogs_ValidationRun_ValidationRunId", + schema: "destination", + table: "RuleExecutionLogs", + column: "ValidationRunId", + principalSchema: "datachecker", + principalTable: "ValidationRun", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_RuleExecutionLogs_ValidationRun_ValidationRunId", + schema: "destination", + table: "RuleExecutionLogs"); + + migrationBuilder.DropTable( + name: "ValidationRun", + schema: "datachecker"); + + migrationBuilder.DropIndex( + name: "IX_RuleExecutionLogs_ValidationRunId", + schema: "destination", + table: "RuleExecutionLogs"); + + migrationBuilder.DropColumn( + name: "ValidationRunId", + schema: "destination", + table: "RuleExecutionLogs"); + } + } +} diff --git a/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230203191115_ValidationRunTableSetNullableCorrectColumns.Designer.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230203191115_ValidationRunTableSetNullableCorrectColumns.Designer.cs new file mode 100644 index 0000000..46a1d46 --- /dev/null +++ b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230203191115_ValidationRunTableSetNullableCorrectColumns.Designer.cs @@ -0,0 +1,520 @@ +// +using System; +using MSDF.DataChecker.Persistence.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace MSDF.DataChecker.Persistence.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20230203191115_ValidationRunTableSetNullableCorrectColumns")] + partial class ValidationRunTableSetNullableCorrectColumns + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Catalogs.Catalog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CatalogType") + .HasColumnType("nvarchar(350)") + .HasMaxLength(350); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(350)") + .HasMaxLength(350); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Catalogs","core"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContainerTypeId") + .HasColumnType("int"); + + b.Property("CreatedByUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateUpdated") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EnvironmentType") + .HasColumnType("int"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("ParentContainerId") + .HasColumnType("uniqueidentifier"); + + b.Property("RuleDetailsDestinationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ContainerTypeId"); + + b.HasIndex("ParentContainerId"); + + b.HasIndex("RuleDetailsDestinationId"); + + b.ToTable("Containers","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.ContainerType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ContainerTypes","core"); + + b.HasData( + new + { + Id = 1, + Name = "Collection" + }, + new + { + Id = 2, + Name = "Folder" + }); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.DatabaseEnvironments.DatabaseEnvironment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("DataSource") + .HasColumnType("nvarchar(max)"); + + b.Property("Database") + .HasColumnType("nvarchar(max)"); + + b.Property("ExtraData") + .HasColumnType("nvarchar(max)"); + + b.Property("MapTables") + .HasColumnType("nvarchar(max)"); + + b.Property("MaxNumberResults") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .HasColumnType("nvarchar(max)"); + + b.Property("SecurityIntegrated") + .HasColumnType("bit"); + + b.Property("TimeoutInMinutes") + .HasColumnType("int"); + + b.Property("User") + .HasColumnType("nvarchar(max)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("DatabaseEnvironments","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Logs.Log", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DateCreated") + .HasColumnType("datetime2"); + + b.Property("Information") + .HasColumnType("nvarchar(max)"); + + b.Property("Source") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Logs","core"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogDetails.EdFiRuleExecutionLogDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("CourseCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Discriminator") + .HasColumnType("nvarchar(max)"); + + b.Property("EducationOrganizationId") + .HasColumnType("int"); + + b.Property("OtherDetails") + .HasColumnType("nvarchar(max)"); + + b.Property("ProgramName") + .HasColumnType("nvarchar(max)"); + + b.Property("RuleExecutionLogId") + .HasColumnType("int"); + + b.Property("StaffUniqueId") + .HasColumnType("nvarchar(max)"); + + b.Property("StudentUniqueId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("RuleExecutionLogId"); + + b.ToTable("EdFiRuleExecutionLogDetails","destination"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("DatabaseEnvironmentId") + .HasColumnType("uniqueidentifier"); + + b.Property("DetailsSchema") + .HasColumnType("nvarchar(max)"); + + b.Property("DetailsTableName") + .HasColumnType("nvarchar(max)"); + + b.Property("DiagnosticSql") + .HasColumnType("nvarchar(max)"); + + b.Property("Evaluation") + .HasColumnType("bit"); + + b.Property("ExecutedSql") + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutionDate") + .HasColumnType("datetime2"); + + b.Property("ExecutionTimeMs") + .HasColumnType("bigint"); + + b.Property("Response") + .HasColumnType("nvarchar(max)"); + + b.Property("Result") + .HasColumnType("int"); + + b.Property("RuleDetailsDestinationId") + .HasColumnType("int"); + + b.Property("RuleId") + .HasColumnType("uniqueidentifier"); + + b.Property("StatusId") + .HasColumnType("int"); + + b.Property("ValidationRunId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RuleId"); + + b.HasIndex("ValidationRunId"); + + b.ToTable("RuleExecutionLogs","destination"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContainerId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateUpdated") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DiagnosticSql") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorSeverityLevel") + .HasColumnType("int"); + + b.Property("MaxNumberResults") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Resolution") + .HasColumnType("nvarchar(max)"); + + b.Property("RuleIdentification") + .HasColumnType("nvarchar(max)"); + + b.Property("Version") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ContainerId"); + + b.ToTable("Rules","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Tags","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.TagEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("ContainerId") + .HasColumnType("uniqueidentifier"); + + b.Property("RuleId") + .HasColumnType("uniqueidentifier"); + + b.Property("TagId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ContainerId"); + + b.HasIndex("RuleId"); + + b.HasIndex("TagId"); + + b.ToTable("TagEntities","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.UserParams.UserParam", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DatabaseEnvironmentId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("DatabaseEnvironmentId"); + + b.ToTable("UserParams","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.ValidationsRun.ValidationRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("EndTime") + .HasColumnType("datetime2"); + + b.Property("HostDatabase") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HostServer") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RunStatus") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Source") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StartTime") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("ValidationRun","datachecker"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.ContainerType", "ContainerType") + .WithMany() + .HasForeignKey("ContainerTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", "ParentContainer") + .WithMany("ChildContainers") + .HasForeignKey("ParentContainerId"); + + b.HasOne("MSDF.DataChecker.Persistence.Catalogs.Catalog", "RuleDetailsDestination") + .WithMany() + .HasForeignKey("RuleDetailsDestinationId"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogDetails.EdFiRuleExecutionLogDetail", b => + { + b.HasOne("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", "RuleExecutionLog") + .WithMany() + .HasForeignKey("RuleExecutionLogId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.RuleExecutionLogs.RuleExecutionLog", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Rules.Rule", null) + .WithMany("RuleExecutionLogs") + .HasForeignKey("RuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MSDF.DataChecker.Persistence.ValidationsRun.ValidationRun", "ValidationRun") + .WithMany() + .HasForeignKey("ValidationRunId"); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", null) + .WithMany("Rules") + .HasForeignKey("ContainerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.Tags.TagEntity", b => + { + b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", "Container") + .WithMany() + .HasForeignKey("ContainerId"); + + b.HasOne("MSDF.DataChecker.Persistence.Rules.Rule", "Rule") + .WithMany() + .HasForeignKey("RuleId"); + + b.HasOne("MSDF.DataChecker.Persistence.Tags.Tag", "Tag") + .WithMany() + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("MSDF.DataChecker.Persistence.UserParams.UserParam", b => + { + b.HasOne("MSDF.DataChecker.Persistence.DatabaseEnvironments.DatabaseEnvironment", null) + .WithMany("UserParams") + .HasForeignKey("DatabaseEnvironmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230203191115_ValidationRunTableSetNullableCorrectColumns.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230203191115_ValidationRunTableSetNullableCorrectColumns.cs new file mode 100644 index 0000000..947576e --- /dev/null +++ b/MSDF.DataChecker.Migrations.SqlServer/Migrations/20230203191115_ValidationRunTableSetNullableCorrectColumns.cs @@ -0,0 +1,17 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace MSDF.DataChecker.Persistence.Migrations +{ + public partial class ValidationRunTableSetNullableCorrectColumns : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/MSDF.DataChecker.Persistence/Migrations/DatabaseContextModelSnapshot.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/DatabaseContextModelSnapshot.cs similarity index 91% rename from MSDF.DataChecker.Persistence/Migrations/DatabaseContextModelSnapshot.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/DatabaseContextModelSnapshot.cs index 6d4166d..de44907 100644 --- a/MSDF.DataChecker.Persistence/Migrations/DatabaseContextModelSnapshot.cs +++ b/MSDF.DataChecker.Migrations.SqlServer/Migrations/DatabaseContextModelSnapshot.cs @@ -271,10 +271,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StatusId") .HasColumnType("int"); + b.Property("ValidationRunId") + .HasColumnType("int"); + b.HasKey("Id"); b.HasIndex("RuleId"); + b.HasIndex("ValidationRunId"); + b.ToTable("RuleExecutionLogs","destination"); }); @@ -400,6 +405,40 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("UserParams","datachecker"); }); + modelBuilder.Entity("MSDF.DataChecker.Persistence.ValidationsRun.ValidationRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("EndTime") + .HasColumnType("datetime2"); + + b.Property("HostDatabase") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HostServer") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RunStatus") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Source") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StartTime") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("ValidationRun","datachecker"); + }); + modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => { b.HasOne("MSDF.DataChecker.Persistence.Collections.ContainerType", "ContainerType") @@ -433,6 +472,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("RuleId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.HasOne("MSDF.DataChecker.Persistence.ValidationsRun.ValidationRun", "ValidationRun") + .WithMany() + .HasForeignKey("ValidationRunId"); }); modelBuilder.Entity("MSDF.DataChecker.Persistence.Rules.Rule", b => diff --git a/MSDF.DataChecker.Persistence/Migrations/ExecuteScriptsEnd.cs b/MSDF.DataChecker.Migrations.SqlServer/Migrations/ExecuteScriptsEnd.cs similarity index 100% rename from MSDF.DataChecker.Persistence/Migrations/ExecuteScriptsEnd.cs rename to MSDF.DataChecker.Migrations.SqlServer/Migrations/ExecuteScriptsEnd.cs diff --git a/MSDF.DataChecker.Persistence/DatabaseEnvironment/DatabaseEnvironmentCommands.cs b/MSDF.DataChecker.Persistence/DatabaseEnvironment/DatabaseEnvironmentCommands.cs index 9ca5fb3..206075f 100644 --- a/MSDF.DataChecker.Persistence/DatabaseEnvironment/DatabaseEnvironmentCommands.cs +++ b/MSDF.DataChecker.Persistence/DatabaseEnvironment/DatabaseEnvironmentCommands.cs @@ -23,6 +23,7 @@ public class DatabaseEnvironmentCommands : IDatabaseEnvironmentCommands public DatabaseEnvironmentCommands(DatabaseContext db) { _db = db; + //AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); } public async Task AddAsync(DatabaseEnvironment model) @@ -39,6 +40,8 @@ public async Task AddAsync(DatabaseEnvironment model) public async Task UpdateAsync(DatabaseEnvironment model) { + //AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); + //AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); var entity = await _db .DatabaseEnvironments .Where(rec => rec.Id == model.Id) @@ -55,6 +58,7 @@ public async Task UpdateAsync(DatabaseEnvironment model) entity.User = model.User; entity.Version = model.Version; entity.TimeoutInMinutes = model.TimeoutInMinutes; + entity.CreatedDate = System.DateTime.Now; var result = _db.DatabaseEnvironments.Update(entity); await _db.SaveChangesAsync(); diff --git a/MSDF.DataChecker.Persistence/EntityFramework/DatabaseContext.cs b/MSDF.DataChecker.Persistence/EntityFramework/DatabaseContext.cs index fd6c33d..badfc2f 100644 --- a/MSDF.DataChecker.Persistence/EntityFramework/DatabaseContext.cs +++ b/MSDF.DataChecker.Persistence/EntityFramework/DatabaseContext.cs @@ -15,6 +15,8 @@ using MSDF.DataChecker.Persistence.Rules; using MSDF.DataChecker.Persistence.Tags; using MSDF.DataChecker.Persistence.UserParams; +using MSDF.DataChecker.Persistence.ValidationsRun; +using System; namespace MSDF.DataChecker.Persistence.EntityFramework { @@ -23,11 +25,14 @@ public class DatabaseContext : DbContext public DatabaseContext(DbContextOptions options) : base(options) { this.ChangeTracker.AutoDetectChangesEnabled = false; + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); + AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); } public DbSet Containers { get; set; } public DbSet ContainerTypes { get; set; } public DbSet Rules { get; set; } public DbSet Logs { get; set; } + public DbSet ValidationRuns { get; set; } public DbSet RuleExecutionLogs { get; set; } public DbSet DatabaseEnvironments { get; set; } public DbSet UserParams { get; set; } diff --git a/MSDF.DataChecker.Persistence/MSDF.DataChecker.Persistence.csproj b/MSDF.DataChecker.Persistence/MSDF.DataChecker.Persistence.csproj index 7af3868..47bff8f 100644 --- a/MSDF.DataChecker.Persistence/MSDF.DataChecker.Persistence.csproj +++ b/MSDF.DataChecker.Persistence/MSDF.DataChecker.Persistence.csproj @@ -1,38 +1,15 @@  - netcoreapp3.1 + net7.0 Debug;Release;Publish - - - - - - - - - - - - - - - - - - - - - - - - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -42,7 +19,7 @@ - + diff --git a/MSDF.DataChecker.Persistence/Migrations/20191204194230_Initial.Designer.cs b/MSDF.DataChecker.Persistence/Migrations/20191204194230_Initial.Designer.cs deleted file mode 100644 index 541e4f1..0000000 --- a/MSDF.DataChecker.Persistence/Migrations/20191204194230_Initial.Designer.cs +++ /dev/null @@ -1,151 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Licensed to the Ed-Fi Alliance under one or more agreements. -// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. -// See the LICENSE and NOTICES files in the project root for more information. - -// -using System; -using MSDF.DataChecker.Persistence.EntityFramework; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace MSDF.DataChecker.Persistence.Migrations -{ - [DbContext(typeof(DatabaseContext))] - [Migration("20191204194230_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ContainerTypeId"); - - b.Property("Name"); - - b.Property("ParentContainerId"); - - b.HasKey("Id"); - - b.HasIndex("ContainerTypeId"); - - b.HasIndex("ParentContainerId"); - - b.ToTable("Containers"); - - b.HasData( - new - { - Id = new Guid("6b1c64ac-a9ce-4441-b552-c3da9a3cea0e"), - ContainerTypeId = 1, - Name = "Ed-Fi" - }, - new - { - Id = new Guid("8d59b9bf-ded0-43f1-9397-3becf7720a8a"), - ContainerTypeId = 2, - Name = "General Sanity Checks", - ParentContainerId = new Guid("6b1c64ac-a9ce-4441-b552-c3da9a3cea0e") - }); - }); - - modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.ContainerType", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("Description"); - - b.Property("Name"); - - b.HasKey("Id"); - - b.ToTable("ContainerTypes"); - - b.HasData( - new - { - Id = 1, - Name = "Collection" - }, - new - { - Id = 2, - Name = "Folder" - }); - }); - - modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Rule", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("ContainerId"); - - b.Property("JSON"); - - b.HasKey("Id"); - - b.HasIndex("ContainerId"); - - b.ToTable("Rules"); - - b.HasData( - new - { - Id = new Guid("a2be65cb-8f54-4694-8c23-72161e351acd"), - ContainerId = new Guid("8d59b9bf-ded0-43f1-9397-3becf7720a8a"), - JSON = @"{ - ""Id"": ""a2be65cb-8f54-4694-8c23-72161e351acd"", - ""Name"": ""Orphaned student records"", - ""Category"": ""Enrollment"", - ""Sql"": ""SELECT count(*) FROM edfi.Student s LEFT JOIN edfi.StudentSchoolAssociation ssa on s.StudentUSI = ssa.StudentUSI WHERE ssa.SchoolId is null;"", - ""DiagnosticSql"": ""SELECT top (100) s.StudentUSI, ssa.SchoolId FROM edfi.Student s LEFT JOIN edfi.StudentSchoolAssociation ssa on s.StudentUSI = ssa.StudentUSI WHERE ssa.SchoolId is null;"", - ""ErrorMessage"": ""You have {TestResult.Result} orphaned student records. These are students that are in your ODS but not associated with any school."", - ""ErrorSeverityLevel"": ""Warning"", - ""Resolution"": ""Look at your student roster and ensure you associate all students with schools."", - ""EvaluationOperand"": ""=="", - ""ExpectedResult"": 0, - ""EdFiODSCompatibilityVersion"": ""3.1"", - ""Version"": ""1.0.0"", - ""Enabled"": 1 -}" - }); - }); - - modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Container", b => - { - b.HasOne("MSDF.DataChecker.Persistence.Collections.ContainerType", "ContainerType") - .WithMany() - .HasForeignKey("ContainerTypeId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("MSDF.DataChecker.Persistence.Collections.Container", "ParentContainer") - .WithMany("ChildContainers") - .HasForeignKey("ParentContainerId"); - }); - - modelBuilder.Entity("MSDF.DataChecker.Persistence.Collections.Rule", b => - { - b.HasOne("MSDF.DataChecker.Persistence.Collections.Container") - .WithMany("Rules") - .HasForeignKey("ContainerId") - .OnDelete(DeleteBehavior.Cascade); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/MSDF.DataChecker.Persistence/Migrations/20191204194230_Initial.cs b/MSDF.DataChecker.Persistence/Migrations/20191204194230_Initial.cs deleted file mode 100644 index 6adf38c..0000000 --- a/MSDF.DataChecker.Persistence/Migrations/20191204194230_Initial.cs +++ /dev/null @@ -1,285 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// Licensed to the Ed-Fi Alliance under one or more agreements. -// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. -// See the LICENSE and NOTICES files in the project root for more information. - -using System; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MSDF.DataChecker.Persistence.Migrations -{ - public partial class Initial : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ContainerTypes", - columns: table => new - { - Id = table.Column(nullable: false) - .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), - Description = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_ContainerTypes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Containers", - columns: table => new - { - Id = table.Column(nullable: false), - Name = table.Column(nullable: true), - ContainerTypeId = table.Column(nullable: false), - ParentContainerId = table.Column(nullable: true), - IsDefault = table.Column(nullable: false,defaultValue:false) - }, - constraints: table => - { - table.PrimaryKey("PK_Containers", x => x.Id); - table.ForeignKey( - name: "FK_Containers_ContainerTypes_ContainerTypeId", - column: x => x.ContainerTypeId, - principalTable: "ContainerTypes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Containers_Containers_ParentContainerId", - column: x => x.ParentContainerId, - principalTable: "Containers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Rules", - columns: table => new - { - Id = table.Column(nullable: false), - ContainerId = table.Column(nullable: false), - Name = table.Column(nullable: true), - Description = table.Column(nullable: true), - ErrorMessage = table.Column(nullable: false), - ErrorSeverityLevel = table.Column(nullable: false, defaultValue:1 ), - Resolution = table.Column(nullable: false), - Sql = table.Column(nullable: false), - DiagnosticSql = table.Column(nullable: false), - EvaluationOperand = table.Column(nullable: false), - ExpectedResult = table.Column(nullable: false, defaultValue: 0), - EdFiODSCompatibilityVersion = table.Column(nullable: false), - Version = table.Column(nullable: false), - Enabled= table.Column(nullable: false, defaultValue: false), - - }, - constraints: table => - { - table.PrimaryKey("PK_Rules", x => x.Id); - table.ForeignKey( - name: "FK_Rules_Containers_ContainerId", - column: x => x.ContainerId, - principalTable: "Containers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "RuleExecutionLogs", - columns: table => new - { - Id = table.Column(nullable: false).Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), - RuleId = table.Column(nullable: false), - Response= table.Column(nullable: false), - Result = table.Column(nullable: false), - ExecutionTimeMs = table.Column(nullable: false), - Evaluation = table.Column(nullable: false), - StatusId = table.Column(nullable: false), - ExecutionDate= table.Column(nullable: false), - }, - constraints: table => - { - table.PrimaryKey("PK_RuleExecutionLogs", x => x.Id); - table.ForeignKey( - name: "FK_RuleExecutionLogs_Rules_RuleId", - column: x => x.RuleId, - principalTable: "Rules", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.InsertData( - table: "ContainerTypes", - columns: new[] { "Id", "Description", "Name" }, - values: new object[] { 1, null, "Collection" }); - - migrationBuilder.InsertData( - table: "ContainerTypes", - columns: new[] { "Id", "Description", "Name" }, - values: new object[] { 2, null, "Folder" }); - - migrationBuilder.InsertData( - table: "ContainerTypes", - columns: new[] { "Id", "Description", "Name" }, - values: new object[] { 3, null, "Rule" }); - - migrationBuilder.InsertData( - table: "Containers", - columns: new[] { "Id", "ContainerTypeId", "Name", "ParentContainerId" }, - values: new object[] { new Guid("6b1c64ac-a9ce-4441-b552-c3da9a3cea0e"), 1, "Ed-Fi", null }); - - migrationBuilder.InsertData( - table: "Containers", - columns: new[] { "Id", "ContainerTypeId", "Name", "ParentContainerId","IsDefault" }, - values: new object[] { new Guid("8d59b9bf-ded0-43f1-9397-3becf7720a8a"), 1, "General Sanity Checks", null ,true}); - - - migrationBuilder.InsertData( - table: "Containers", - columns: new[] { "Id", "ContainerTypeId", "Name", "ParentContainerId" }, - values: new object[] { new Guid("36e8573a-9a5e-4a4a-a044-90766895dca7"), 1, "TestCollection", null }); - - - migrationBuilder.InsertData( - table: "Containers", - columns: new[] { "Id", "ContainerTypeId", "Name", "ParentContainerId" }, - values: new object[] { new Guid("8ec30964-5951-46a2-a5d8-7cdb8703483f"), 2, "Enrollment", new Guid("8d59b9bf-ded0-43f1-9397-3becf7720a8a") }); - - migrationBuilder.InsertData( - table: "Containers", - columns: new[] { "Id", "ContainerTypeId", "Name", "ParentContainerId" }, - values: new object[] { new Guid("5c57a680-1222-4566-b27a-cc2d15c783da"), 2, "Student Identification and Demographics", new Guid("8d59b9bf-ded0-43f1-9397-3becf7720a8a") }); - - - //migrationBuilder.InsertData( - // table: "Rules", - // columns: new[] { "Id", "ContainerId", "JSON" }, - // values: new object[] { new Guid("a2be65cb-8f54-4694-8c23-72161e351acd"), new Guid("8ec30964-5951-46a2-a5d8-7cdb8703483f"), @"{ - // ""Id"": ""a2be65cb-8f54-4694-8c23-72161e351acd"", - // ""Name"": ""Orphaned student records"", - // ""Category"": ""Enrollment"", - // ""Sql"": ""SELECT count(*) FROM edfi.Student s LEFT JOIN edfi.StudentSchoolAssociation ssa on s.StudentUSI = ssa.StudentUSI WHERE ssa.SchoolId is null;"", - // ""DiagnosticSql"": ""SELECT top (100) s.StudentUSI, ssa.SchoolId FROM edfi.Student s LEFT JOIN edfi.StudentSchoolAssociation ssa on s.StudentUSI = ssa.StudentUSI WHERE ssa.SchoolId is null;"", - // ""ErrorMessage"": ""You have {TestResult.Result} orphaned student records. These are students that are in your ODS but not associated with any school."", - // ""ErrorSeverityLevel"": ""Warning"", - // ""Resolution"": ""Look at your student roster and ensure you associate all students with schools."", - // ""EvaluationOperand"": ""=="", - // ""ExpectedResult"": 0, - // ""EdFiODSCompatibilityVersion"": ""3.1"", - // ""Version"": ""1.0.0"", - // ""Enabled"": 1 - // }" }); - - migrationBuilder.InsertData( - table: "Rules", - columns: new[] { "Id", "ContainerId", "Name" ,"SQL","DiagnosticSql","ErrorMessage", "ErrorSeverityLevel" ,"Resolution", - "EvaluationOperand","ExpectedResult","EdFiODSCompatibilityVersion","Version","Enabled","Description"}, - values: new object[] { new Guid("226fc670-1132-4758-b797-3994869a34a8"), new Guid("8ec30964-5951-46a2-a5d8-7cdb8703483f"), - "School Count Check", - "SELECT count(*) FROM edfi.School;", - "SELECT top (100) s.StudentUSI, ssa.SchoolId FROM edfi.Student s LEFT JOIN edfi.StudentSchoolAssociation ssa on s.StudentUSI = ssa.StudentUSI WHERE ssa.SchoolId is null", - "School count is {TestResult.Result}. Ensure that you have loaded enough data into the edfi.School table.", - 3, - "Load data into the edfi.School table.", - ">", - 1000, - "3.1", - "1.0.0", - true, - "descriptionhere" - }); - - //migrationBuilder.InsertData( - // table: "Rules", - // columns: new[] { "Id", "ContainerId", "JSON" }, - // values: new object[] { new Guid("b2be65cb-8f54-4694-8c23-72161e351acd"), new Guid("8ec30964-5951-46a2-a5d8-7cdb8703483f"), @"{ - // ""Id"": ""b2be65cb-8f54-4694-8c23-72161e351acd"", - // ""Name"": ""Students Associated With Parents That are not associated with a School"", - // ""Category"": ""Enrollment"", - // ""Sql"": ""SELECT count(*) FROM [edfi].[ParentElectronicMail] pem inner join [edfi].StudentParentAssociation spa on pem.ParentUSI = spa.ParentUSI inner join [edfi].Student s on spa.StudentUSI = s.StudentUSI left join [edfi].StudentSchoolAssociation ssa on s.StudentUSI = ssa.StudentUSI left join [edfi].EducationOrganization edorg on ssa.SchoolId = edorg.EducationOrganizationId WHERE ssa.SchoolId is null"", - // ""DiagnosticSql"": ""SELECT top (100) pem.ParentUSI, pem.ElectronicMailAddress, s.StudentUSI, s.FirstName, s.LastSurname, ssa.SchoolId FROM [edfi].[ParentElectronicMail] pem inner join [edfi].StudentParentAssociation spa on pem.ParentUSI = spa.ParentUSI inner join [edfi].Student s on spa.StudentUSI = s.StudentUSI left join [edfi].StudentSchoolAssociation ssa on s.StudentUSI = ssa.StudentUSI left join [edfi].EducationOrganization edorg on ssa.SchoolId = edorg.EducationOrganizationId WHERE ssa.SchoolId is null"", - // ""ErrorMessage"": ""You have {TestResult.Result} students associated with parents that are not associated with a school. These are students that are in your ODS but not associated with any school."", - // ""ErrorSeverityLevel"": ""Critical"", - // ""Resolution"": ""Ensure all your students are associated with a school. Talk to your registrar to see how you can fix this."", - // ""EvaluationOperand"": ""=="", - // ""ExpectedResult"": 0, - // ""EdFiODSCompatibilityVersion"": ""3.1"", - // ""Version"": ""1.0.0"", - // ""Enabled"": 1 - // } - // " }); - - //migrationBuilder.InsertData( - // table: "Rules", - // columns: new[] { "Id", "ContainerId", "JSON" }, - // values: new object[] { new Guid("7066cb17-82bd-421a-aae1-a11391244896"), new Guid("5c57a680-1222-4566-b27a-cc2d15c783da"), @"{ - // ""Id"": ""7066cb17-82bd-421a-aae1-a11391244896"", - // ""Name"": ""Student Count Check"", - // ""Category"": ""Student Identification and Demographics"", - // ""Sql"": ""SELECT count(*) FROM edfi.Student;"", - // ""ErrorMessage"": ""Student count is 0. Ensure that you have loaded data into the edfi.Student table."", - // ""ErrorSeverityLevel"": ""Critical"", - // ""Resolution"": ""Load data into the edfi.Student table."", - // ""EvaluationOperand"": "">"", - // ""ExpectedResult"": 0, - // ""EdFiODSCompatibilityVersion"": ""3.1"", - // ""Version"": ""1.0.0"", - // ""Enabled"": 1 - // } - // " }); - - - //migrationBuilder.InsertData( - // table: "Rules", - // columns: new[] { "Id", "ContainerId", "JSON" }, - // values: new object[] { new Guid("362be894-7bfa-4868-9ba6-73b9dd426737"), new Guid("5c57a680-1222-4566-b27a-cc2d15c783da"), @"{ - // ""Id"": ""362be894-7bfa-4868-9ba6-73b9dd426737"", - // ""Name"": ""Teacher Candidates with No Race"", - // ""Category"": ""TPDM"", - // ""Sql"": ""SELECT count(*) FROM [EdFi_Ods_Populated_TPDM].[tpdm].TeacherCandidate tc LEFT JOIN tpdm.TeacherCandidateRace tcr on tc.TeacherCandidateIdentifier = tcr.TeacherCandidateIdentifier WHERE RaceDescriptorId is null;"", - // ""DiagnosticSql"": ""SELECT top(1000) tc.TeacherCandidateIdentifier, tcr.RaceDescriptorId FROM [EdFi_Ods_Populated_TPDM].[tpdm].TeacherCandidate tc LEFT JOIN tpdm.TeacherCandidateRace tcr on tc.TeacherCandidateIdentifier = tcr.TeacherCandidateIdentifier WHERE RaceDescriptorId is null;"", - // ""ErrorMessage"": ""You have {TestResult.Result} teacher candidates with no race associated with them. These are teacher candidates that are in your ODS but not associated with any Race descriptor."", - // ""ErrorSeverityLevel"": ""Warning"", - // ""Resolution"": ""Look at your teacher candidate roster and ensure you associate all of them with Race."", - // ""EvaluationOperand"": ""=="", - // ""ExpectedResult"": 0, - // ""EdFiODSCompatibilityVersion"": ""3.1"", - // ""Version"": ""1.0.0"", - // ""Enabled"": 1 - //} - // " }); - - - migrationBuilder.CreateIndex( - name: "IX_Containers_ContainerTypeId", - table: "Containers", - column: "ContainerTypeId"); - - migrationBuilder.CreateIndex( - name: "IX_Containers_ParentContainerId", - table: "Containers", - column: "ParentContainerId"); - - migrationBuilder.CreateIndex( - name: "IX_Rules_ContainerId", - table: "Rules", - column: "ContainerId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Rules"); - - migrationBuilder.DropTable( - name: "Containers"); - - migrationBuilder.DropTable( - name: "ContainerTypes"); - - migrationBuilder.DropTable( - name: "RuleExecutionLogs"); - } - } -} diff --git a/MSDF.DataChecker.Persistence/Providers/DbAccessProvider.cs b/MSDF.DataChecker.Persistence/Providers/DbAccessProvider.cs index d3c22fc..8269989 100644 --- a/MSDF.DataChecker.Persistence/Providers/DbAccessProvider.cs +++ b/MSDF.DataChecker.Persistence/Providers/DbAccessProvider.cs @@ -23,7 +23,8 @@ public class DbAccessProvider : IDbAccessProvider { public void PostgresSQL(IServiceCollection configuration, string ConnectionStrings) { - configuration.AddDbContext(opt => opt.UseNpgsql(ConnectionStrings)); + configuration.AddDbContext(opt => opt.UseNpgsql(ConnectionStrings, x => x.MigrationsAssembly("MSDF.DataChecker.Migrations.Postgres"))); + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); configuration.AddHangfire(globalConfiguration => globalConfiguration .SetDataCompatibilityLevel(CompatibilityLevel.Version_170) .UseSimpleAssemblyNameTypeSerializer() @@ -37,8 +38,11 @@ public void PostgresSQL(IServiceCollection configuration, string ConnectionStrin } public void SQLServer(IServiceCollection configuration, string ConnectionStrings) + { - configuration.AddDbContext(options => options.UseSqlServer(ConnectionStrings), ServiceLifetime.Transient); + + configuration.AddDbContext(options => options.UseSqlServer(ConnectionStrings, x => x.MigrationsAssembly("MSDF.DataChecker.Migrations.SqlServer")) ,ServiceLifetime.Transient); + //configuration.AddDbContext(options => options.UseSqlServer(ConnectionStrings), ServiceLifetime.Transient); configuration.AddHangfire(globalConfiguration => globalConfiguration .SetDataCompatibilityLevel(CompatibilityLevel.Version_170) .UseSimpleAssemblyNameTypeSerializer() diff --git a/MSDF.DataChecker.Persistence/RuleExecutionLogs/RuleExecutionLog.cs b/MSDF.DataChecker.Persistence/RuleExecutionLogs/RuleExecutionLog.cs index dce4384..ce94acb 100644 --- a/MSDF.DataChecker.Persistence/RuleExecutionLogs/RuleExecutionLog.cs +++ b/MSDF.DataChecker.Persistence/RuleExecutionLogs/RuleExecutionLog.cs @@ -1,10 +1,11 @@ -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: Apache-2.0 // Licensed to the Ed-Fi Alliance under one or more agreements. // The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. // See the LICENSE and NOTICES files in the project root for more information. using System; using System.ComponentModel.DataAnnotations.Schema; +using MSDF.DataChecker.Persistence.ValidationsRun; namespace MSDF.DataChecker.Persistence.RuleExecutionLogs { @@ -25,5 +26,10 @@ public class RuleExecutionLog public int? RuleDetailsDestinationId { get; set; } public string DetailsSchema { get; set; } public string DetailsTableName { get; set; } + + + public int? ValidationRunId { get; set; } + [ForeignKey("ValidationRunId")] + public ValidationRun ValidationRun { get; set; } } } diff --git a/MSDF.DataChecker.Persistence/ValidationsRun/ValidationRun.cs b/MSDF.DataChecker.Persistence/ValidationsRun/ValidationRun.cs new file mode 100644 index 0000000..0cf1013 --- /dev/null +++ b/MSDF.DataChecker.Persistence/ValidationsRun/ValidationRun.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; +using MSDF.DataChecker.Persistence.RuleExecutionLogs; + +namespace MSDF.DataChecker.Persistence.ValidationsRun +{ + [Table("ValidationRun", Schema = "datachecker")] + public class ValidationRun + { + public int Id { get; set; } + [Required(AllowEmptyStrings = false)] + public string RunStatus { get; set; } + + + [Required(AllowEmptyStrings = false)] + public string HostServer { get; set; } + [Required(AllowEmptyStrings = false)] + public string HostDatabase { get; set; } + [Required(AllowEmptyStrings = false)] + public string Source { get; set; } + public DateTime StartTime { get; set; } + public DateTime? EndTime { get; set; } + } +} diff --git a/MSDF.DataChecker.Persistence/ValidationsRun/ValidationRunCommands.cs b/MSDF.DataChecker.Persistence/ValidationsRun/ValidationRunCommands.cs new file mode 100644 index 0000000..42863f8 --- /dev/null +++ b/MSDF.DataChecker.Persistence/ValidationsRun/ValidationRunCommands.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using MSDF.DataChecker.Persistence.EntityFramework; + +namespace MSDF.DataChecker.Persistence.ValidationsRun +{ + public interface IValidationRunCommands + { + Task AddAsync(ValidationRun validationRun); + Task UpdateAsync(ValidationRun validationRun); + } + + public class ValidationRunCommands : IValidationRunCommands + { + private readonly DatabaseContext _db; + public ValidationRunCommands(DatabaseContext db) + { + _db = db; + } + + public async Task AddAsync(ValidationRun validationRun) + { + _db.Entry(validationRun).State = EntityState.Added; + var result = this._db.Add(validationRun); + await this._db.SaveChangesAsync(); + return result.Entity; + } + + public async Task UpdateAsync(ValidationRun model) + { + var entity = await _db.ValidationRuns + .FirstOrDefaultAsync(rec => rec.Id == model.Id); + + if (entity != null) + { + entity.EndTime = model.EndTime; + entity.HostDatabase = model.HostDatabase; + entity.HostServer = model.HostServer; + entity.Id = model.Id; + entity.RunStatus = model.RunStatus; + entity.Source = model.Source; + entity.StartTime = model.StartTime; + + _db.ValidationRuns.Update(entity); + await _db.SaveChangesAsync(); + return entity; + } + return null; + + } + } +} diff --git a/MSDF.DataChecker.Persistence/ValidationsRun/ValidationRunQueries.cs b/MSDF.DataChecker.Persistence/ValidationsRun/ValidationRunQueries.cs new file mode 100644 index 0000000..3fc00e3 --- /dev/null +++ b/MSDF.DataChecker.Persistence/ValidationsRun/ValidationRunQueries.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using MSDF.DataChecker.Persistence.EntityFramework; + +namespace MSDF.DataChecker.Persistence.ValidationsRun +{ + public interface IValidationRunQueries + { + Task> GetAsync(); + Task GetAsync(int id); + } + public class ValidationRunQueries : IValidationRunQueries + { + private readonly DatabaseContext _db; + public ValidationRunQueries(DatabaseContext db) + { + _db = db; + } + + public async Task> GetAsync() + { + var models = await _db.ValidationRuns + .OrderByDescending(m => m.Id) + .ToListAsync(); + + return models; + } + + public async Task GetAsync(int id) + { + var model = await _db.ValidationRuns + .Where(rec => rec.Id == id) + .FirstOrDefaultAsync(); + return model; + } + } +} diff --git a/MSDF.DataChecker.RuleExec/Helpers/CommandLine.cs b/MSDF.DataChecker.RuleExec/Helpers/CommandLine.cs index 2e369f2..2c70fee 100644 --- a/MSDF.DataChecker.RuleExec/Helpers/CommandLine.cs +++ b/MSDF.DataChecker.RuleExec/Helpers/CommandLine.cs @@ -1,4 +1,6 @@ using Microsoft.Extensions.DependencyInjection; +using MSDF.DataChecker.Persistence; +using MSDF.DataChecker.Persistence.ValidationsRun; using MSDF.DataChecker.Services; using MSDF.DataChecker.Services.Models; using MSDF.DataChecker.Services.RuleExecution; @@ -101,10 +103,11 @@ public static DatabaseEnvironmentBO BuildDatabaseEnvironment(string connString, if (Engine == "SqlServer") { isPostgres = false; - builderSql = new SqlConnectionStringBuilder(connString); + + builderSql = new SqlConnectionStringBuilder(Utility.ParseConnectionString(connString, Engine)); } else - builderNpgsql = new NpgsqlConnectionStringBuilder(connString); + builderNpgsql = new NpgsqlConnectionStringBuilder(Utility.ParseConnectionString(connString, Engine)); dbEnvironment.Database = isPostgres ? builderNpgsql.Database : builderSql.InitialCatalog; dbEnvironment.DataSource = isPostgres ? builderNpgsql.Host : builderSql.DataSource; @@ -142,6 +145,7 @@ public static List RulesToExecute( public static async Task ExecuteRuleByEnvironmentId( IContainerService _containerService, + IValidationRunService _validationRunService, IRuleService _ruleService, IRuleExecService _executionService, IDatabaseEnvironmentService _databaseEnvironmentService, @@ -171,10 +175,22 @@ public static async Task ExecuteRuleByEnvironmentId( toRun.AddRange(resultRules.Rules); toRun = toRun.Where(r => r.Id != Guid.Empty).ToList(); databaseEnvironment.UserParams = new List(); + databaseEnvironment = await _databaseEnvironmentService.GetAsync(databaseEnvironment.Id); + var validationRun = new ValidationRunBO + { + HostDatabase = databaseEnvironment.Database, + HostServer = databaseEnvironment.DataSource, + RunStatus = "Running", + Source = "Manual", + StartTime = DateTime.Now + }; + + var validationResult = await _validationRunService.AddAsync(validationRun); + foreach (var r in toRun) { - databaseEnvironment = await _databaseEnvironmentService.GetAsync(databaseEnvironment.Id); - result = await _executionService.ExecuteRuleByEnvironmentIdAsync(r.Id, databaseEnvironment); + + result = await _executionService.ExecuteRuleByEnvironmentIdAsync(validationResult.Id, r.Id, databaseEnvironment); } return result; } diff --git a/MSDF.DataChecker.RuleExec/MSDF.DataChecker.RuleExec.csproj b/MSDF.DataChecker.RuleExec/MSDF.DataChecker.RuleExec.csproj index 3d1bb0a..3054a29 100644 --- a/MSDF.DataChecker.RuleExec/MSDF.DataChecker.RuleExec.csproj +++ b/MSDF.DataChecker.RuleExec/MSDF.DataChecker.RuleExec.csproj @@ -2,12 +2,12 @@ Exe - netcoreapp3.1 + net7.0 Debug;Release;Publish - + diff --git a/MSDF.DataChecker.RuleExec/Program.cs b/MSDF.DataChecker.RuleExec/Program.cs index df648f1..367af17 100644 --- a/MSDF.DataChecker.RuleExec/Program.cs +++ b/MSDF.DataChecker.RuleExec/Program.cs @@ -10,6 +10,7 @@ using MSDF.DataChecker.Persistence.Settings; using MSDF.DataChecker.RuleExec.Helpers; using MSDF.DataChecker.Services; +using MSDF.DataChecker.Services.Models; using MSDF.DataChecker.Services.RuleExecution; using System; using System.CommandLine; @@ -42,9 +43,11 @@ static int Main(string[] args) var _executionService = serviceProvider.GetService(); var _catalogService = serviceProvider.GetService(); var _databaseEnvironmentService = serviceProvider.GetService(); + var _validationRunService = serviceProvider.GetService(); + var listEnvironments = _databaseEnvironmentService.GetAsync().GetAwaiter().GetResult(); var collection = CommandLine.BuildCollectionJsonRule(sqlRules, ruleName); - var settings = configuration.GetSection("Settings").Get(); + var settings = configuration.GetSection("DatabaseSettings").Get(); var dbEnvironment = CommandLine.BuildDatabaseEnvironment(connString, settings.Engine); var databaseEnvironment = listEnvironments.FirstOrDefault(rec => rec.Name == dbEnvironment.Database && rec.DataSource == dbEnvironment.DataSource); @@ -56,12 +59,23 @@ static int Main(string[] args) databaseEnvironment = await _databaseEnvironmentService.GetAsync(databaseEnvironment.Id); } + var validationRun = new ValidationRunBO + { + HostDatabase = databaseEnvironment.Database, + HostServer = databaseEnvironment.DataSource, + RunStatus = "Running", + Source = "Manual", + StartTime = DateTime.Now + }; + + var validationResult = await _validationRunService.AddAsync(validationRun); + await _containerService.UploadCollectionAsJson(collection); var rulesToExecute = CommandLine.RulesToExecute(_containerService, _ruleService, collection); foreach (var r in rulesToExecute) { - var result = await _executionService.ExecuteRuleByEnvironmentIdAsync(r.Id, databaseEnvironment); + var result = await _executionService.ExecuteRuleByEnvironmentIdAsync(validationResult.Id, r.Id, databaseEnvironment); } return; diff --git a/MSDF.DataChecker.RuleExec/appsettings.json b/MSDF.DataChecker.RuleExec/appsettings.json index db8b5f0..06af053 100644 --- a/MSDF.DataChecker.RuleExec/appsettings.json +++ b/MSDF.DataChecker.RuleExec/appsettings.json @@ -1,10 +1,10 @@ { "DatabaseSettings": { - "Engine": "Postgres", //SqlServer OR Postgres + "Engine": "SqlServer", //SqlServer OR Postgres "ConnectionStrings": { "PostgresSql": "Server=localhost;Port=5432;Database=DataCheckerPersistence1;User Id=postgres;Password=yourpassword;", - "SqlServer": "Data Source=host.docker.internal; Database=DataCheckerPersistence; Integrated Security=true; Persist Security Info=True;" + "SqlServer": "Data Source=localhost;Database=DataCheckerPersistence;User Id=myuser;Password=mypassword;TrustServerCertificate=true" } }, "EncryptionKey": "M2c240FUeEbs5SxxO1vra721t1T41xwO", diff --git a/MSDF.DataChecker.Services/DatabaseEnvironmentService.cs b/MSDF.DataChecker.Services/DatabaseEnvironmentService.cs index fe23ddb..17de277 100644 --- a/MSDF.DataChecker.Services/DatabaseEnvironmentService.cs +++ b/MSDF.DataChecker.Services/DatabaseEnvironmentService.cs @@ -145,6 +145,7 @@ public async Task UpdateAsync(DatabaseEnvironmentBO model environment.SecurityIntegrated = model.SecurityIntegrated; environment.MapTables = model.MapTables; environment.Version = model.Version; + environment.MaxNumberResults = model.MaxNumberResults; environment.TimeoutInMinutes = model.TimeoutInMinutes; if (environment.SecurityIntegrated != null && environment.SecurityIntegrated.Value) diff --git a/MSDF.DataChecker.Services/JobService.cs b/MSDF.DataChecker.Services/JobService.cs index 569b180..1bc0e77 100644 --- a/MSDF.DataChecker.Services/JobService.cs +++ b/MSDF.DataChecker.Services/JobService.cs @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: Apache-2.0 // Licensed to the Ed-Fi Alliance under one or more agreements. // The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. // See the LICENSE and NOTICES files in the project root for more information. diff --git a/MSDF.DataChecker.Services/MSDF.DataChecker.Services.csproj b/MSDF.DataChecker.Services/MSDF.DataChecker.Services.csproj index 480e655..03397ab 100644 --- a/MSDF.DataChecker.Services/MSDF.DataChecker.Services.csproj +++ b/MSDF.DataChecker.Services/MSDF.DataChecker.Services.csproj @@ -1,13 +1,13 @@  - netcoreapp3.1 + net7.0 Debug;Release;Publish - - + + diff --git a/MSDF.DataChecker.Services/Models/JobBO.cs b/MSDF.DataChecker.Services/Models/JobBO.cs index e95cc07..1601f56 100644 --- a/MSDF.DataChecker.Services/Models/JobBO.cs +++ b/MSDF.DataChecker.Services/Models/JobBO.cs @@ -37,9 +37,11 @@ public class JobRunner private readonly IContainerService _containerService; private readonly IDatabaseEnvironmentService _databaseEnvironmentService; private readonly IRuleExecService _executionService; + private IValidationRunService _validationRunService; public JobRunner(ITagService tagService, IContainerService containerService, + IValidationRunService validationRunService, IDatabaseEnvironmentService databaseEnvironmentService, IRuleExecService executionService, IRuleService ruleService) @@ -47,6 +49,7 @@ public JobRunner(ITagService tagService, _tagService = tagService; _containerService = containerService; _databaseEnvironmentService = databaseEnvironmentService; + _validationRunService = validationRunService; _executionService = executionService; _ruleService = ruleService; } @@ -82,11 +85,35 @@ public async Task Run(JobBO job) var result = await _ruleService.SearchRulesAsync(collections, containers, tags, string.Empty, string.Empty, null, null); toRun.AddRange(result.Rules); toRun = toRun.Where(r => r.Id != Guid.Empty).ToList(); + var validationRun = new ValidationRunBO + { + HostDatabase = databaseEnvironment.Database, + HostServer = databaseEnvironment.DataSource, + RunStatus = "Running", + Source = "Scheduled", + StartTime = DateTime.UtcNow + }; + + var validationResult = await _validationRunService.AddAsync(validationRun); foreach (var r in toRun) { - await _executionService.ExecuteRuleByEnvironmentIdAsync(r.Id, databaseEnvironment); + await _executionService.ExecuteRuleByEnvironmentIdAsync(validationResult.Id, r.Id, databaseEnvironment); } + validationRun.EndTime = DateTime.UtcNow; + validationRun.RunStatus = "Finished"; + validationRun.Id = validationResult.Id; + + try + { + await _validationRunService.UpdateAsync(validationRun); + + } + catch (Exception ex) + { + } + + } } } diff --git a/MSDF.DataChecker.Services/Models/ValidationRunBO.cs b/MSDF.DataChecker.Services/Models/ValidationRunBO.cs new file mode 100644 index 0000000..ce3b3c0 --- /dev/null +++ b/MSDF.DataChecker.Services/Models/ValidationRunBO.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace MSDF.DataChecker.Services.Models +{ + public class ValidationRunBO + { + public int Id { get; set; } + public Guid DatabaseEnvironmentId { get; set; } + public string RunStatus { get; set; } + public string HostServer { get; set; } + public string HostDatabase { get; set; } + public string Source { get; set; } + public DateTime StartTime { get; set; } + public DateTime? EndTime { get; set; } + } +} diff --git a/MSDF.DataChecker.Services/RuleExecution/RuleExecService.cs b/MSDF.DataChecker.Services/RuleExecution/RuleExecService.cs index ace8cfd..652860b 100644 --- a/MSDF.DataChecker.Services/RuleExecution/RuleExecService.cs +++ b/MSDF.DataChecker.Services/RuleExecution/RuleExecService.cs @@ -5,6 +5,7 @@ using MSDF.DataChecker.Persistence.RuleExecutionLogDetails; using MSDF.DataChecker.Persistence.RuleExecutionLogs; using MSDF.DataChecker.Persistence.Settings; +using MSDF.DataChecker.Persistence.ValidationsRun; using MSDF.DataChecker.Services.Models; using Npgsql; using System; @@ -22,7 +23,7 @@ public interface IRuleExecService string ConnectionString { get; set; } IDataProvider DataProvider { get; } Task> ExecuteRulesByEnvironmentIdAsync(List rules, DatabaseEnvironmentBO databaseEnvironment); - Task ExecuteRuleByEnvironmentIdAsync(Guid ruleId, DatabaseEnvironmentBO databaseEnvironment); + Task ExecuteRuleByEnvironmentIdAsync(int validationRunId,Guid ruleId, DatabaseEnvironmentBO databaseEnvironment); Task ExecuteRuleDiagnosticByRuleLogIdAndEnvironmentIdAsync(int ruleLogId, DatabaseEnvironmentBO databaseEnvironment); Task ExecuteRuleAsync(RuleBO rule, string connectionString, List userParams, int? timeout); } @@ -30,6 +31,7 @@ public class RuleExecService : IRuleExecService { private readonly IRuleService _ruleService; private readonly IRuleExecutionLogCommands _ruleExecutionLogCommands; + private readonly IValidationRunCommands _validationRunCommands; private readonly IRuleExecutionLogQueries _ruleExecutionLogQueries; private readonly IRuleExecutionLogDetailCommands _edFiRuleExecutionLogDetailCommands; private readonly IRuleExecutionLogDetailQueries _edFiRuleExecutionLogDetailQueries; @@ -47,6 +49,7 @@ public string ConnectionString public RuleExecService( IRuleService ruleService , IRuleExecutionLogCommands ruleExecutionLogCommands + , IValidationRunCommands validationRunCommands , IRuleExecutionLogQueries ruleExecutionLogQueries , IRuleExecutionLogDetailCommands edFiRuleExecutionLogDetailCommands , ICatalogQueries catalogQueries @@ -57,6 +60,7 @@ IRuleService ruleService { _ruleService = ruleService; _ruleExecutionLogCommands = ruleExecutionLogCommands; + _validationRunCommands=validationRunCommands; _ruleExecutionLogQueries = ruleExecutionLogQueries; _edFiRuleExecutionLogDetailCommands = edFiRuleExecutionLogDetailCommands; _catalogQueries = catalogQueries; @@ -78,10 +82,11 @@ public async Task> ExecuteRulesByEnvironmentIdAsync(List ExecuteRuleByEnvironmentIdAsync(Guid ruleId, DatabaseEnvironmentBO databaseEnvironment) + public async Task ExecuteRuleByEnvironmentIdAsync(int validationRunId,Guid ruleId, DatabaseEnvironmentBO databaseEnvironment) { int? ruleDetailsDestinationId = null; var rule = await _ruleService.GetAsync(ruleId); + rule.MaxNumberResults = databaseEnvironment.MaxNumberResults; var executionLogs = await _ruleExecutionLogQueries.GetByRuleIdAsync(ruleId); var connectionString = databaseEnvironment.GetConnectionString(_appSettings.Engine); @@ -90,7 +95,7 @@ public async Task ExecuteRuleByEnvironmentIdAsync(Guid ruleId, D if (string.IsNullOrEmpty(_dataProvider.ConnectionString)) _dataProvider.ConnectionString = connectionString; - RuleTestResult testResult = await ExecuteRuleAsync(rule, connectionString, databaseEnvironment.UserParams, databaseEnvironment.TimeoutInMinutes); + var testResult = await ExecuteRuleAsync(rule, connectionString, databaseEnvironment.UserParams, databaseEnvironment.TimeoutInMinutes); var containerParent = await _collectionQueries.GetAsync(rule.ContainerId); if (containerParent.ParentContainerId != null) @@ -98,8 +103,8 @@ public async Task ExecuteRuleByEnvironmentIdAsync(Guid ruleId, D var collectionParent = await _collectionQueries.GetAsync(containerParent.ParentContainerId.Value); ruleDetailsDestinationId = collectionParent.RuleDetailsDestinationId; } - - RuleExecutionLog ruleExecutionLog = new RuleExecutionLog() + + var ruleExecutionLog = new RuleExecutionLog() { Id = 0, Evaluation = testResult.Evaluation, @@ -110,16 +115,17 @@ public async Task ExecuteRuleByEnvironmentIdAsync(Guid ruleId, D DatabaseEnvironmentId = databaseEnvironment.Id, ExecutedSql = testResult.ExecutedSql, DiagnosticSql = rule.DiagnosticSql, - RuleDetailsDestinationId = ruleDetailsDestinationId + RuleDetailsDestinationId = ruleDetailsDestinationId, + ValidationRunId = validationRunId, }; + if (ruleExecutionLog.RuleDetailsDestinationId == null || ruleExecutionLog.RuleDetailsDestinationId.Value == 0) ruleExecutionLog.RuleDetailsDestinationId = null; testResult.LastExecuted = executionLogs.Any() ? executionLogs.FirstOrDefault().ExecutionDate : (DateTime?)null; ruleExecutionLog.ExecutionTimeMs = stopWatch.ElapsedMilliseconds; ruleExecutionLog.Result = testResult.Result; - var newRuleExecutionLog = await _ruleExecutionLogCommands.AddAsync(ruleExecutionLog); testResult.TestResults = await _ruleService.GetTopResults(ruleId, databaseEnvironment.Id); @@ -139,8 +145,7 @@ public async Task ExecuteRuleByEnvironmentIdAsync(Guid ruleId, D int maxNumberResults = databaseEnvironment.MaxNumberResults.Value; if (rule.MaxNumberResults != null) maxNumberResults = rule.MaxNumberResults.Value; - - await InsertDiagnosticSqlIntoDetails(rule, newRuleExecutionLog, connectionString, databaseEnvironment.UserParams, existCatalog.Name, maxNumberResults,_appSettings.Engine); + testResult.Result = await InsertDiagnosticSqlIntoDetails(rule, newRuleExecutionLog, connectionString, databaseEnvironment.UserParams, existCatalog.Name, maxNumberResults, _appSettings.Engine); } } } @@ -153,7 +158,6 @@ public async Task ExecuteRuleByEnvironmentIdAsync(Guid ruleId, D return testResult; } - public Task ExecuteRuleAsync(RuleBO rule, string connectionString, List userParams, int? timeout) { var stopWatch = System.Diagnostics.Stopwatch.StartNew(); @@ -166,7 +170,8 @@ public Task ExecuteRuleAsync(RuleBO rule, string connectionStrin int execution = 0; bool resultWithErrors = false; - string sqlToRun = Utils.GenerateSqlWithCount(rule.DiagnosticSql,_appSettings.Engine); + var sqlToexecute = Utils.GenerateSqlWithTop(rule.DiagnosticSql, rule.MaxNumberResults.ToString(), _appSettings.Engine); + //var sqlToRun = Utils.GenerateSqlWithCount(rule.DiagnosticSql, _appSettings.Engine); var parameters = new Dictionary(); userParams.ForEach(item => { parameters.Add(item.Name, item.Value); }); @@ -174,17 +179,9 @@ public Task ExecuteRuleAsync(RuleBO rule, string connectionStrin if (string.IsNullOrEmpty(_dataProvider.ConnectionString)) _dataProvider.ConnectionString = connectionString; - - - if (string.IsNullOrEmpty(sqlToRun)) - { - sqlToRun = rule.DiagnosticSql; - var dataReader = _dataProvider.ExecuteReader(connectionString, sqlToRun, parameters); - if (dataReader.Rows.Count > 0) - execution = dataReader.Rows.Count; - } - else - execution = Convert.ToInt32(_dataProvider.ExecuteScalar(connectionString, sqlToRun, parameters)); + var dataReaderRows = _dataProvider.ExecuteReader(connectionString, sqlToexecute, parameters); + if (dataReaderRows.Rows.Count > 0) + execution = dataReaderRows.Rows.Count; resultWithErrors = execution > 0; testResult = new RuleTestResult @@ -195,7 +192,7 @@ public Task ExecuteRuleAsync(RuleBO rule, string connectionStrin Evaluation = !resultWithErrors, Status = !resultWithErrors ? Status.Succeded : Status.Failed, ErrorMessage = !resultWithErrors ? "" : rule.ErrorMessage, - ExecutedSql = rule.DiagnosticSql + ExecutedSql = sqlToexecute }; } catch (Exception e) @@ -215,7 +212,6 @@ public Task ExecuteRuleAsync(RuleBO rule, string connectionStrin testResult.ExecutionTimeMs = stopWatch.ElapsedMilliseconds; return Task.FromResult(testResult); } - public TableResult GetExecutedRuleDiagnosticByRuleLog(DataTable dt) { var diagnosticResult = new TableResult(); @@ -259,7 +255,7 @@ public async Task ExecuteRuleDiagnosticByRuleLogIdAndEnvironmentIdA return diagnosticResult; } - private async Task InsertDiagnosticSqlIntoDetails(RuleBO rule, RuleExecutionLog ruleExecutionLog, string connectionString, List sqlParams, string tableName, int maxNumberResults,string engine) + private async Task InsertDiagnosticSqlIntoDetails(RuleBO rule, RuleExecutionLog ruleExecutionLog, string connectionString, List sqlParams, string tableName, int maxNumberResults,string engine) { var tableForSqlBulk = new DataTable(); string sqlToRun = Utils.GenerateSqlWithTop(rule.DiagnosticSql, maxNumberResults.ToString(), engine); @@ -283,10 +279,12 @@ private async Task InsertDiagnosticSqlIntoDetails(RuleBO rule, RuleExecutionLog if (ruleExecutionLog != null) { ruleExecutionLog.DetailsSchema = columnsSchema; + ruleExecutionLog.Result = tableForSqlBulk.Rows.Count; await _ruleExecutionLogCommands.UpdateAsync(ruleExecutionLog); } await _edFiRuleExecutionLogDetailCommands.ExecuteSqlBulkCopy(tableForSqlBulk, $"[destination].[{tableName}]",_appSettings.Engine); } + return tableForSqlBulk.Rows.Count; } } } diff --git a/MSDF.DataChecker.Services/RuleExecutionService.cs b/MSDF.DataChecker.Services/RuleExecutionService.cs index 31ea3ad..61ce6f6 100644 --- a/MSDF.DataChecker.Services/RuleExecutionService.cs +++ b/MSDF.DataChecker.Services/RuleExecutionService.cs @@ -131,7 +131,7 @@ public async Task ExecuteRuleByEnvironmentIdAsync(Guid ruleId,Da if (rule.MaxNumberResults != null) maxNumberResults = rule.MaxNumberResults.Value; - await InsertDiagnosticSqlIntoDetails(rule, newRuleExecutionLog, connectionString, databaseEnvironment.UserParams, existCatalog.Name, maxNumberResults,_appSettings.Engine); + testResult.Result= await InsertDiagnosticSqlIntoDetails(rule, newRuleExecutionLog, connectionString, databaseEnvironment.UserParams, existCatalog.Name, maxNumberResults,_appSettings.Engine); } } } @@ -292,7 +292,7 @@ public async Task ExecuteRuleDiagnosticByRuleLogIdAndEnvironmentIdA return result; } - private async Task InsertDiagnosticSqlIntoDetails(RuleBO rule, RuleExecutionLog ruleExecutionLog, string connectionString, List sqlParams, string tableName, int maxNumberResults,string engine) + private async Task InsertDiagnosticSqlIntoDetails(RuleBO rule, RuleExecutionLog ruleExecutionLog, string connectionString, List sqlParams, string tableName, int maxNumberResults,string engine) { string sqlToRun = Utils.GenerateSqlWithTop(rule.DiagnosticSql, maxNumberResults.ToString(), engine); string columnsSchema = string.Empty; @@ -315,10 +315,12 @@ private async Task InsertDiagnosticSqlIntoDetails(RuleBO rule, RuleExecutionLog if (ruleExecutionLog != null) { ruleExecutionLog.DetailsSchema = columnsSchema; + ruleExecutionLog.Result = tableToInsert.Rows.Count; await _ruleExecutionLogCommands.UpdateAsync(ruleExecutionLog); } await _edFiRuleExecutionLogDetailCommands.ExecuteSqlBulkCopy(tableToInsert, $"[destination].[{tableName}]",_appSettings.Engine); } + return tableToInsert.Rows.Count; } } } diff --git a/MSDF.DataChecker.Services/Utils.cs b/MSDF.DataChecker.Services/Utils.cs index 5ea30e5..116eb84 100644 --- a/MSDF.DataChecker.Services/Utils.cs +++ b/MSDF.DataChecker.Services/Utils.cs @@ -4,6 +4,7 @@ // See the LICENSE and NOTICES files in the project root for more information. using Microsoft.Data.SqlClient; +using Microsoft.Extensions.FileSystemGlobbing.Internal; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; @@ -11,11 +12,14 @@ using System.Data.Common; using System.Linq; using System.Text.RegularExpressions; +using static System.Net.Mime.MediaTypeNames; namespace MSDF.DataChecker.Services { public static class Utils { + private static GroupCollection selectGroups; + public static List> Serialize(List columnsName, List rows) { var results = new List>(); @@ -25,101 +29,126 @@ public static List> Serialize(List columnsNam } return results; } - + public static string FindDateFromDiagnosticSql(string diagnosticSql, string Engine) { + if (Engine == "SqlServer") + { + diagnosticSql = Regex.Replace(diagnosticSql, @"now\(\)", @"getDate()", RegexOptions.IgnoreCase); + } + else if (Engine == "Postgres") + { + diagnosticSql = Regex.Replace(diagnosticSql, @"getDate\(\)", @"now()", RegexOptions.IgnoreCase); + } + return diagnosticSql; + } public static string GenerateSqlWithTop(string diagnosticSql, string maxNumberResults, string Engine) { - string result = diagnosticSql; - result = result.ToLower().Trim(); + //Replacing multiple spaces BUT NOT LineBreaks + var limitOfRecords = ""; + var limitValue = ""; + var topValue = ""; + var selectStatement = ""; + var result = Regex.Replace(diagnosticSql, @"[^\S\r\n]+", " ").Replace(";", ""); + if (result.EndsWith(";")) { - result = result.Remove(result.Length-1,1); + result = result.Remove(result.Length - 1, 1); } - var topValue = ""; + var limitExpression = @"top\s+\d+"; - var limitGroups = Regex.Match(result, limitExpression).Groups; + var limitGroups = Regex.Match(result, limitExpression, RegexOptions.IgnoreCase).Groups; if (limitGroups[0].Success) { topValue = limitGroups[0].Value; result = result.Replace(limitGroups[0].Value, ""); } - - var limitValue = ""; limitExpression = @"limit\s+\d+"; - limitGroups = Regex.Match(result, limitExpression).Groups; + limitGroups = Regex.Match(result, limitExpression, RegexOptions.IgnoreCase).Groups; if (limitGroups[0].Success) { limitValue = limitGroups[0].Value; result = result.Replace(limitGroups[0].Value, ""); } + if (Engine == "SqlServer" && !string.IsNullOrEmpty(limitValue)) { - topValue = limitValue.Replace("limit", "top"); + topValue = limitValue.Replace("limit", "top"); } else if (Engine == "Postgres" && !string.IsNullOrEmpty(topValue)) { - limitValue = topValue.Replace("top","Limit"); + limitValue = topValue.Replace("top", "Limit"); } - if (result.StartsWith("select")) - { + if (result.ToLower().StartsWith("select")) + { //the statment start with 'select' + var selectRegex = new Regex(@"select\s+", RegexOptions.IgnoreCase); + var m = selectRegex.Match(result); // m is the first match + if (m.Success) + { + selectStatement = m.Value; + result = selectRegex.Replace(result, $"", 1); + } + //the statment start with 'distinct' + var distinctRegex = new Regex(@"distinct\s+", RegexOptions.IgnoreCase); + m = distinctRegex.Match(result); // m is the first match + if (m.Success) + { + selectStatement += string.Format("{0} {1}", "", m.Value); + result = distinctRegex.Replace(result, $"", 1); + } + if (Engine == "SqlServer") { - var regex = new Regex(Regex.Escape("select distinct")); - if (regex.IsMatch(result)) - { - var top = topValue==string.Empty ? $" top {maxNumberResults}" : topValue; - result = regex.Replace(result, $"select distinct {top} ", 1); - } - else + if (!string.IsNullOrEmpty(maxNumberResults) || !string.IsNullOrEmpty(topValue)) { - regex = new Regex(Regex.Escape("select")); - if (regex.IsMatch(result)) - { - var top = topValue == string.Empty ? $" top {maxNumberResults}" : topValue; - result = regex.Replace(result, $"select {top} ", 1); - } + limitOfRecords = topValue == string.Empty ? $" top {maxNumberResults}" : topValue; + selectStatement += string.Format("{0} {1}", limitOfRecords, result); + } + else { + selectStatement += string.Format(" {0}", result); } } else { - string pattern = @"limit\s+\d+"; - Match m = Regex.Match(result, pattern, RegexOptions.IgnoreCase); - if (!m.Success) + if (!string.IsNullOrEmpty(maxNumberResults) || !string.IsNullOrEmpty(limitValue)) { - limitValue = limitValue == string.Empty ? " Limit " + maxNumberResults : limitValue; - result = result + " " + limitValue; + limitOfRecords = limitValue == string.Empty ? " Limit " + maxNumberResults : limitValue; + selectStatement += string.Format("{0} {1}", result, limitOfRecords); + } + else + { + selectStatement += string.Format(" {0}", result); } } - } - else if (result.StartsWith("with")) + result = string.Format("{0};", selectStatement); + }else if (result.ToLower().StartsWith("with")) { - if (!result.Contains(") select top")) + if (!result.ToLower().Contains(") select top")) { if (Engine == "SqlServer") { - if (result.Contains(") select distinct")) + if (result.ToLower().Contains(") select distinct")) { - var regex = new Regex(Regex.Escape(") select distinct")); + var regex = new Regex(Regex.Escape(") select distinct"), RegexOptions.IgnoreCase); result = regex.Replace(result, ") select distinct top " + maxNumberResults + " ", 1); } else { - var regex = new Regex(Regex.Escape(") select")); + var regex = new Regex(Regex.Escape(") select"), RegexOptions.IgnoreCase); result = regex.Replace(result, ") select top " + maxNumberResults + " ", 1); } } } } + result=FindDateFromDiagnosticSql(result, Engine); return result; } - public static string ValidateLimitRows(string diagnosticSql,string engine) + public static string ValidateLimitRows(string diagnosticSql, string engine) { - string result = diagnosticSql; - result = result.ToLower().Trim().Replace(";", ""); - result = result.ToLower().Trim(); + //Replacing line breaks and multiple spaces + var result = Regex.Replace(diagnosticSql, @"[^\S\r\n]+", " ").Replace(";", ""); if (result.EndsWith(";")) { result = result.Remove(result.Length - 1, 1); @@ -127,7 +156,7 @@ public static string ValidateLimitRows(string diagnosticSql,string engine) var topValue = ""; var limitExpression = @"top\s+\d+"; - var limitGroups = Regex.Match(result, limitExpression).Groups; + var limitGroups = Regex.Match(result, limitExpression, RegexOptions.IgnoreCase).Groups; if (limitGroups[0].Success) { topValue = limitGroups[0].Value; @@ -137,7 +166,7 @@ public static string ValidateLimitRows(string diagnosticSql,string engine) var limitValue = ""; limitExpression = @"limit\s+\d+"; - limitGroups = Regex.Match(result, limitExpression).Groups; + limitGroups = Regex.Match(result, limitExpression, RegexOptions.IgnoreCase).Groups; if (limitGroups[0].Success) { limitValue = limitGroups[0].Value; @@ -153,18 +182,18 @@ public static string ValidateLimitRows(string diagnosticSql,string engine) } - if (result.StartsWith("select")) + if (result.ToLower().StartsWith("select")) { if (engine == "SqlServer") { - var regex = new Regex(Regex.Escape("select distinct")); + var regex = new Regex(Regex.Escape("select distinct"), RegexOptions.IgnoreCase); if (regex.IsMatch(result)) { result = regex.Replace(result, $"select distinct {topValue} ", 1); } else { - regex = new Regex(Regex.Escape("select")); + regex = new Regex(Regex.Escape("select"), RegexOptions.IgnoreCase); if (regex.IsMatch(result)) { result = regex.Replace(result, $"select {topValue} ", 1); @@ -179,15 +208,16 @@ public static string ValidateLimitRows(string diagnosticSql,string engine) { result = result + " " + limitValue; } + result = Regex.Replace(result, "getdate", "now", RegexOptions.IgnoreCase); } } return result; } - public static string GenerateSqlWithCount(string diagnosticSql,string engine) + public static string GenerateSqlWithCount(string diagnosticSql, string engine) { - string result = diagnosticSql; - + //Replacing line breaks and multiple spaces + var result = Regex.Replace(Regex.Replace(diagnosticSql.Trim(), @"\r\n?|\n", " "), @"\s+", " ").Replace(";", ""); if (result.StartsWith("select")) { return string.Format("SELECT COUNT(*) FROM ( \n {0} \n) as TBL", ValidateLimitRows(result, engine)); @@ -223,7 +253,7 @@ public static DataTable GetTableForSqlBulk(int ruleExecutionLogId, DataTable rea { List staticColumns = new List(); List jsonColumns = new List(); - var columnsToIgnore = new List() { "id", "otherdetails", "ruleexecutionlogid" }; + var columnsToIgnore = new List() { "id", "otherdetails", "ruleexecutionlogid" }; var columnsSource = reader.Columns; foreach (DataColumn column in columnsSource) diff --git a/MSDF.DataChecker.Services/ValidationRunService.cs b/MSDF.DataChecker.Services/ValidationRunService.cs new file mode 100644 index 0000000..f57e49b --- /dev/null +++ b/MSDF.DataChecker.Services/ValidationRunService.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Options; +using MSDF.DataChecker.Persistence.Providers; +using MSDF.DataChecker.Persistence.Settings; +using MSDF.DataChecker.Persistence.ValidationsRun; +using MSDF.DataChecker.Services.Models; + +namespace MSDF.DataChecker.Services +{ + public interface IValidationRunService + { + Task AddAsync(ValidationRunBO model); + Task UpdateAsync(ValidationRunBO validationRun); + Task> GetAsync(); + Task GetAsync(int id); + } + public class ValidationRunService : IValidationRunService + { + private IValidationRunCommands _validationnRunCommands; + private IValidationRunQueries _validationRunQueries; + private readonly DataBaseSettings _appSettings; + private IDbAccessProvider _dataAccessProvider; + + public ValidationRunService( + IValidationRunCommands validationRunCommands, + IValidationRunQueries validationRunQueries, + IOptions appSettings, + IDbAccessProvider dataAccessProvider) + + { + _validationnRunCommands = validationRunCommands; + _validationRunQueries = validationRunQueries; + _appSettings = appSettings.Value; + _dataAccessProvider = dataAccessProvider; + } + public async Task AddAsync(ValidationRunBO model) + { + var result = await this._validationnRunCommands.AddAsync(MapModelToEntity(model)); + return MapEntityToModel(result); + } + + public async Task UpdateAsync(ValidationRunBO model) + { + var result = await this._validationnRunCommands.UpdateAsync(MapModelToEntity(model)); + return MapEntityToModel(result); + } + public async Task> GetAsync() + { + var validationsRun = await this._validationRunQueries.GetAsync(); + if (validationsRun != null) + return validationsRun + .Select(rec => MapEntityToModel(rec)) + .ToList(); + + return null; + } + + public async Task GetAsync(int id) + { + var validationsRun = await this._validationRunQueries.GetAsync(id); + if (validationsRun != null) + return MapEntityToModel(validationsRun); + + return null; + } + private ValidationRun MapModelToEntity(ValidationRunBO model) + { + var entity = new ValidationRun + { + EndTime = model.EndTime, + HostDatabase = model.HostDatabase, + HostServer = model.HostServer, + RunStatus = model.RunStatus, + Id = model.Id, + Source = model.Source, + StartTime = model.StartTime + }; + return entity; + } + + private ValidationRunBO MapEntityToModel(ValidationRun entity) + { + var model = new ValidationRunBO + { + EndTime = entity.EndTime, + HostDatabase = entity.HostDatabase, + HostServer = entity.HostServer, + RunStatus = entity.RunStatus, + Id = entity.Id, + Source = entity.Source, + StartTime = entity.StartTime + }; + return model; + } + + } +} diff --git a/MSDF.DataChecker.WebApp/ClientApp/src/app/home/home.component.html b/MSDF.DataChecker.WebApp/ClientApp/src/app/home/home.component.html index db3c59d..f57422a 100644 --- a/MSDF.DataChecker.WebApp/ClientApp/src/app/home/home.component.html +++ b/MSDF.DataChecker.WebApp/ClientApp/src/app/home/home.component.html @@ -149,7 +149,7 @@

{{ collectionName }}