From eda2f09b2af1b17ccb7890227639eff20047bb8f Mon Sep 17 00:00:00 2001 From: Adam Hopkins <127156771+simpat-adam@users.noreply.github.com> Date: Sat, 30 Sep 2023 10:00:24 -0500 Subject: [PATCH] [ODS-5988] Remove OdsInstance from Application (#837) * Remove ODSInstance from Application * Remove test * Package updates --- .../Models/Application.cs | 4 +- Application/EdFi.Ods.Api/EdFi.Ods.Api.csproj | 2 +- .../EdFi.Ods.Sandbox/EdFi.Ods.Sandbox.csproj | 2 +- .../EdFi.Ods.Tests/EdFi.Ods.Tests.csproj | 2 +- ...0170-Drop-OdsInstance-From-Application.sql | 22 ++++++ ...0170-Drop-OdsInstance-From-Application.sql | 12 +++ .../Models/UserContextMappingTests.cs | 75 ------------------- ...i.Ods.WebApi.CompositeSpecFlowTests.csproj | 2 +- .../EdFi.Ods.WebApi.IntegrationTests.csproj | 2 +- 9 files changed, 40 insertions(+), 83 deletions(-) create mode 100644 Artifacts/MsSql/Structure/Admin/0170-Drop-OdsInstance-From-Application.sql create mode 100644 Artifacts/PgSql/Structure/Admin/0170-Drop-OdsInstance-From-Application.sql diff --git a/Application/EdFi.Admin.DataAccess/Models/Application.cs b/Application/EdFi.Admin.DataAccess/Models/Application.cs index bcab6be9ad..360de595de 100644 --- a/Application/EdFi.Admin.DataAccess/Models/Application.cs +++ b/Application/EdFi.Admin.DataAccess/Models/Application.cs @@ -29,9 +29,7 @@ public Application() public string ClaimSetName { get; set; } public virtual Vendor Vendor { get; set; } - - public virtual OdsInstance OdsInstance { get; set; } - + [StringLength(255)] [Required] public string OperationalContextUri { get; set; } diff --git a/Application/EdFi.Ods.Api/EdFi.Ods.Api.csproj b/Application/EdFi.Ods.Api/EdFi.Ods.Api.csproj index 55b6bfda3e..d418b791b3 100644 --- a/Application/EdFi.Ods.Api/EdFi.Ods.Api.csproj +++ b/Application/EdFi.Ods.Api/EdFi.Ods.Api.csproj @@ -26,7 +26,7 @@ - + diff --git a/Application/EdFi.Ods.Sandbox/EdFi.Ods.Sandbox.csproj b/Application/EdFi.Ods.Sandbox/EdFi.Ods.Sandbox.csproj index 2dec0a2833..2d74684837 100644 --- a/Application/EdFi.Ods.Sandbox/EdFi.Ods.Sandbox.csproj +++ b/Application/EdFi.Ods.Sandbox/EdFi.Ods.Sandbox.csproj @@ -20,7 +20,7 @@ - + diff --git a/Application/EdFi.Ods.Tests/EdFi.Ods.Tests.csproj b/Application/EdFi.Ods.Tests/EdFi.Ods.Tests.csproj index 30bc90a889..f328cf6250 100644 --- a/Application/EdFi.Ods.Tests/EdFi.Ods.Tests.csproj +++ b/Application/EdFi.Ods.Tests/EdFi.Ods.Tests.csproj @@ -27,7 +27,7 @@ - + diff --git a/Artifacts/MsSql/Structure/Admin/0170-Drop-OdsInstance-From-Application.sql b/Artifacts/MsSql/Structure/Admin/0170-Drop-OdsInstance-From-Application.sql new file mode 100644 index 0000000000..a8bc1fdbf7 --- /dev/null +++ b/Artifacts/MsSql/Structure/Admin/0170-Drop-OdsInstance-From-Application.sql @@ -0,0 +1,22 @@ +-- 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. + +IF OBJECT_ID('dbo.FK_Applications_OdsInstances', 'F') IS NOT NULL +BEGIN + ALTER TABLE [dbo].[Applications] DROP CONSTRAINT [FK_Applications_OdsInstances] +END + +IF EXISTS (SELECT 1 + FROM sys.indexes I + WHERE I.Name = 'IX_OdsInstance_OdsInstanceId' -- Index name + AND I.object_id = OBJECT_ID('dbo.Applications')) +BEGIN + DROP INDEX [IX_OdsInstance_OdsInstanceId] ON [dbo].[Applications] +END + +IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Applications' AND COLUMN_NAME = 'OdsInstance_OdsInstanceId') +BEGIN + ALTER TABLE [dbo].[Applications] DROP COLUMN [OdsInstance_OdsInstanceId] +END \ No newline at end of file diff --git a/Artifacts/PgSql/Structure/Admin/0170-Drop-OdsInstance-From-Application.sql b/Artifacts/PgSql/Structure/Admin/0170-Drop-OdsInstance-From-Application.sql new file mode 100644 index 0000000000..07e5532dee --- /dev/null +++ b/Artifacts/PgSql/Structure/Admin/0170-Drop-OdsInstance-From-Application.sql @@ -0,0 +1,12 @@ +-- 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. + +ALTER TABLE dbo.Applications + DROP CONSTRAINT IF EXISTS FK_Applications_OdsInstances; + +DROP INDEX IF EXISTS IX_OdsInstance_OdsInstanceId; + +ALTER TABLE dbo.Applications + DROP COLUMN IF EXISTS OdsInstance_OdsInstanceId; \ No newline at end of file diff --git a/tests/EdFi.Admin.DataAccess.IntegrationTests/Models/UserContextMappingTests.cs b/tests/EdFi.Admin.DataAccess.IntegrationTests/Models/UserContextMappingTests.cs index 11a77daee2..255fba83d4 100644 --- a/tests/EdFi.Admin.DataAccess.IntegrationTests/Models/UserContextMappingTests.cs +++ b/tests/EdFi.Admin.DataAccess.IntegrationTests/Models/UserContextMappingTests.cs @@ -238,81 +238,6 @@ public void Should_create_lea_association() } } - public class When_adding_an_ods_to_an_application : UserContextTestBase - { - private string vendorName; - private string appName; - private string odsName; - private string connectionString; - private const string ClaimSetName = "ClaimSet"; - - [OneTimeSetUp] - public new void Setup() - { - vendorName = string.Format("{0}_TestData", DateTime.Now.Ticks); - appName = string.Format("{0}_TestData", DateTime.Now.Ticks); - odsName = string.Format("{0}_TestData", DateTime.Now.Ticks); - connectionString = string.Format("{0}_TestData", DateTime.Now.Ticks); - } - - [Test] - public void Should_create_ods_and_context_and_derivative() - { - //Arrange - var vendor = new Vendor { VendorName = vendorName }; - - vendor.CreateApplication(appName, ClaimSetName); - - using (var context = GetUsersContextTest()) - { - vendor.Applications.AsEnumerable() - .ElementAt(0) - .OperationalContextUri = "uri://ed-fi-api-host.org"; - - vendor.Applications.AsEnumerable() - .ElementAt(0) - .OdsInstance = new OdsInstance - { - Name = odsName, - ConnectionString = connectionString, - InstanceType = "TEST" - }; - - vendor.Applications.AsEnumerable() - .ElementAt(0) - .OdsInstance.OdsInstanceContexts.Add( - new OdsInstanceContext - { - ContextKey = "TESTKEY", - ContextValue = "TESTVALUE" - }); - - vendor.Applications.AsEnumerable() - .ElementAt(0) - .OdsInstance.OdsInstanceDerivatives.Add( - new OdsInstanceDerivative - { - ConnectionString = connectionString, - DerivativeType = "TEST" - }); - - context.Vendors.Add(vendor); - context.SaveChangesForTest(); - - //Act - var application = context.Applications.Where(app => app.ApplicationName == appName) - .Include(x => x.OdsInstance) - .Single(); - - //Test - application.OdsInstance.Name.ShouldBe(odsName); - application.OdsInstance.ConnectionString.ShouldBe(connectionString); - application.OdsInstance.OdsInstanceContexts.Count.ShouldBe(1); - application.OdsInstance.OdsInstanceDerivatives.Count.ShouldBe(1); - } - } - } - public class When_creating_ods_context : UserContextTestBase { private string odsName; diff --git a/tests/EdFi.Ods.WebApi.CompositeSpecFlowTests/EdFi.Ods.WebApi.CompositeSpecFlowTests.csproj b/tests/EdFi.Ods.WebApi.CompositeSpecFlowTests/EdFi.Ods.WebApi.CompositeSpecFlowTests.csproj index 5051f3c451..9feea73676 100644 --- a/tests/EdFi.Ods.WebApi.CompositeSpecFlowTests/EdFi.Ods.WebApi.CompositeSpecFlowTests.csproj +++ b/tests/EdFi.Ods.WebApi.CompositeSpecFlowTests/EdFi.Ods.WebApi.CompositeSpecFlowTests.csproj @@ -31,7 +31,7 @@ - + diff --git a/tests/EdFi.Ods.WebApi.IntegrationTests/EdFi.Ods.WebApi.IntegrationTests.csproj b/tests/EdFi.Ods.WebApi.IntegrationTests/EdFi.Ods.WebApi.IntegrationTests.csproj index b6055011bd..51c07e4299 100644 --- a/tests/EdFi.Ods.WebApi.IntegrationTests/EdFi.Ods.WebApi.IntegrationTests.csproj +++ b/tests/EdFi.Ods.WebApi.IntegrationTests/EdFi.Ods.WebApi.IntegrationTests.csproj @@ -22,7 +22,7 @@ - +