diff --git a/src/Core/AdminConsole/Entities/OrganizationIntegration.cs b/src/Core/AdminConsole/Entities/OrganizationIntegration.cs index 18f8be8667..86de25ce9a 100644 --- a/src/Core/AdminConsole/Entities/OrganizationIntegration.cs +++ b/src/Core/AdminConsole/Entities/OrganizationIntegration.cs @@ -12,7 +12,7 @@ public class OrganizationIntegration : ITableObject public Guid OrganizationId { get; set; } public IntegrationType Type { get; set; } public string? Configuration { get; set; } - public DateTime CreationDate { get; set; } = DateTime.UtcNow; + public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; public DateTime RevisionDate { get; set; } = DateTime.UtcNow; public void SetNewId() => Id = CoreHelpers.GenerateComb(); } diff --git a/src/Core/AdminConsole/Entities/OrganizationIntegrationConfiguration.cs b/src/Core/AdminConsole/Entities/OrganizationIntegrationConfiguration.cs index 7592d0c763..25b669622f 100644 --- a/src/Core/AdminConsole/Entities/OrganizationIntegrationConfiguration.cs +++ b/src/Core/AdminConsole/Entities/OrganizationIntegrationConfiguration.cs @@ -13,7 +13,7 @@ public class OrganizationIntegrationConfiguration : ITableObject public EventType EventType { get; set; } public string? Configuration { get; set; } public string? Template { get; set; } - public DateTime CreationDate { get; set; } = DateTime.UtcNow; + public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; public DateTime RevisionDate { get; set; } = DateTime.UtcNow; public void SetNewId() => Id = CoreHelpers.GenerateComb(); } diff --git a/src/Infrastructure.EntityFramework/AdminConsole/Configurations/OrganizationIntegrationConfigurationEntityTypeConfiguration.cs b/src/Infrastructure.EntityFramework/AdminConsole/Configurations/OrganizationIntegrationConfigurationEntityTypeConfiguration.cs index 29712f5e38..a5df0845bd 100644 --- a/src/Infrastructure.EntityFramework/AdminConsole/Configurations/OrganizationIntegrationConfigurationEntityTypeConfiguration.cs +++ b/src/Infrastructure.EntityFramework/AdminConsole/Configurations/OrganizationIntegrationConfigurationEntityTypeConfiguration.cs @@ -9,7 +9,7 @@ public class OrganizationIntegrationConfigurationEntityTypeConfiguration : IEnti public void Configure(EntityTypeBuilder builder) { builder - .Property(p => p.Id) + .Property(oic => oic.Id) .ValueGeneratedNever(); builder.ToTable(nameof(OrganizationIntegrationConfiguration)); diff --git a/src/Infrastructure.EntityFramework/AdminConsole/Configurations/OrganizationIntegrationEntityTypeConfiguration.cs b/src/Infrastructure.EntityFramework/AdminConsole/Configurations/OrganizationIntegrationEntityTypeConfiguration.cs index c2134c1b7d..3434d735d0 100644 --- a/src/Infrastructure.EntityFramework/AdminConsole/Configurations/OrganizationIntegrationEntityTypeConfiguration.cs +++ b/src/Infrastructure.EntityFramework/AdminConsole/Configurations/OrganizationIntegrationEntityTypeConfiguration.cs @@ -9,15 +9,15 @@ public class OrganizationIntegrationEntityTypeConfiguration : IEntityTypeConfigu public void Configure(EntityTypeBuilder builder) { builder - .Property(p => p.Id) + .Property(oi => oi.Id) .ValueGeneratedNever(); builder - .HasIndex(p => p.OrganizationId) + .HasIndex(oi => oi.OrganizationId) .IsClustered(false); builder - .HasIndex(p => new { p.OrganizationId, p.Type }) + .HasIndex(oi => new { oi.OrganizationId, oi.Type }) .IsUnique() .IsClustered(false); diff --git a/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationRepository.cs b/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationRepository.cs index c095b07030..a5f4f0bd9d 100644 --- a/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationRepository.cs +++ b/src/Infrastructure.EntityFramework/AdminConsole/Repositories/OrganizationRepository.cs @@ -199,6 +199,8 @@ public class OrganizationRepository : Repository po.OrganizationId == organization.Id) .ExecuteDeleteAsync(); + await dbContext.OrganizationIntegrations.Where(oi => oi.OrganizationId == organization.Id) + .ExecuteDeleteAsync(); await dbContext.GroupServiceAccountAccessPolicy.Where(ap => ap.GrantedServiceAccount.OrganizationId == organization.Id) .ExecuteDeleteAsync(); diff --git a/src/Sql/dbo/Stored Procedures/OrganizationIntegrationConfiguration_ReadById.sql b/src/Sql/dbo/Stored Procedures/OrganizationIntegrationConfiguration_ReadById.sql new file mode 100644 index 0000000000..545904c6db --- /dev/null +++ b/src/Sql/dbo/Stored Procedures/OrganizationIntegrationConfiguration_ReadById.sql @@ -0,0 +1,13 @@ +CREATE PROCEDURE [dbo].[OrganizationIntegrationConfiguration_ReadById] + @Id UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + SELECT + * + FROM + [dbo].[OrganizationIntegrationConfiguration] + WHERE + [Id] = @Id +END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/OrganizationIntegration_ReadById.sql b/src/Sql/dbo/Stored Procedures/OrganizationIntegration_ReadById.sql new file mode 100644 index 0000000000..a59fd4b075 --- /dev/null +++ b/src/Sql/dbo/Stored Procedures/OrganizationIntegration_ReadById.sql @@ -0,0 +1,13 @@ +CREATE PROCEDURE [dbo].[OrganizationIntegration_ReadById] + @Id UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + SELECT + * + FROM + [dbo].[OrganizationIntegration] + WHERE + [Id] = @Id +END \ No newline at end of file diff --git a/util/Migrator/DbScripts/2025-04-03_00_OrganizationIntegrationCUD.sql b/util/Migrator/DbScripts/2025-04-03_00_OrganizationIntegrationCUD.sql index da13a2c1fe..dc2336730a 100644 --- a/util/Migrator/DbScripts/2025-04-03_00_OrganizationIntegrationCUD.sql +++ b/util/Migrator/DbScripts/2025-04-03_00_OrganizationIntegrationCUD.sql @@ -1,12 +1,6 @@ -- Configure FK to cascade on delete -IF EXISTS(SELECT * -FROM information_schema.table_constraints -WHERE table_name='OrganizationIntegrationConfiguration' - AND constraint_name='FK_OrganizationIntegrationConfiguration_OrganizationIntegration') -BEGIN - ALTER TABLE [dbo].[OrganizationIntegrationConfiguration] DROP FK_OrganizationIntegrationConfiguration_OrganizationIntegration; - ALTER TABLE [dbo].[OrganizationIntegrationConfiguration] ADD CONSTRAINT [FK_OrganizationIntegrationConfiguration_OrganizationIntegration] FOREIGN KEY ([OrganizationIntegrationId]) REFERENCES [dbo].[OrganizationIntegration] ([Id]) ON DELETE CASCADE; -END +ALTER TABLE [dbo].[OrganizationIntegrationConfiguration] DROP FK_OrganizationIntegrationConfiguration_OrganizationIntegration; +ALTER TABLE [dbo].[OrganizationIntegrationConfiguration] ADD CONSTRAINT [FK_OrganizationIntegrationConfiguration_OrganizationIntegration] FOREIGN KEY ([OrganizationIntegrationId]) REFERENCES [dbo].[OrganizationIntegration] ([Id]) ON DELETE CASCADE; GO CREATE OR ALTER PROCEDURE [dbo].[OrganizationIntegration_Create] @@ -152,3 +146,34 @@ BEGIN WHERE [Id] = @Id END +GO + +CREATE OR ALTER PROCEDURE [dbo].[OrganizationIntegration_ReadById] + @Id UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + SELECT + * + FROM + [dbo].[OrganizationIntegration] + WHERE + [Id] = @Id +END +GO + +CREATE OR ALTER PROCEDURE [dbo].[OrganizationIntegrationConfiguration_ReadById] + @Id UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + SELECT + * + FROM + [dbo].[OrganizationIntegrationConfiguration] + WHERE + [Id] = @Id +END +GO