Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RestrictionName from AttachmentEntity #414

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

CelineTrammi
Copy link
Collaborator

@CelineTrammi CelineTrammi commented Oct 29, 2024

Description

Remove RestrictionName from AttachmentEntity and all mappers.

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Summary by CodeRabbit

  • New Features

    • Enhanced test coverage for correspondence initialization scenarios, including handling of notifications and validation of different templates.
  • Bug Fixes

    • Removed unnecessary RestrictionName property from various data structures and responses, simplifying data handling.
  • Chores

    • Updated Postman collection for API endpoints to ensure proper JSON formatting and compliance.
  • Documentation

    • Updated migration scripts to reflect changes in the database schema by removing the RestrictionName field from the AttachmentEntity.

Copy link
Contributor

coderabbitai bot commented Oct 29, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve the removal of the RestrictionName property from various classes and methods within the Altinn Correspondence API. This includes updates to the formData object in the JavaScript test file, modifications in multiple C# mapper classes, and alterations in the database schema through migration files. The changes aim to simplify the data structures used in correspondence handling and attachment management, ensuring that the RestrictionName is no longer part of the relevant entities or responses.

Changes

File Change Summary
Test/Altinn.Correspondence.LoadTests/test_initialize_and_upload_correspondence.js Removed RestrictionName from attachments array in formData.
Test/Altinn.Correspondence.Tests/CorrespondenceControllerTests.cs Added new test cases and refined existing tests for correspondence initialization scenarios.
Test/Altinn.Correspondence.Tests/Factories/AttachmentBuilder.cs Removed RestrictionName initialization in CreateAttachment method.
Test/Altinn.Correspondence.Tests/Factories/CorrespondenceBuilder.cs Removed RestrictionName from WithAttachments method.
Test/Altinn.Correspondence.Tests/Helpers/AttachmentHelper.cs Removed default value for RestrictionName in GetAttachmentMetaData method.
altinn-correspondence-postman-collection.json Removed trailing commas in JSON objects for various API endpoints.
src/Altinn.Correspondence.API/Mappers/AttachmentDetailsMapper.cs Removed RestrictionName assignment in MapToExternal method.
src/Altinn.Correspondence.API/Mappers/AttachmentOverviewMapper.cs Removed RestrictionName from MapToExternal method.
src/Altinn.Correspondence.API/Mappers/CorrespondenceAttachmentMapper.cs Removed RestrictionName from MapToExternal method.
src/Altinn.Correspondence.API/Mappers/InitializeAttachmentMapper.cs Removed RestrictionName assignment in MapToRequest method.
src/Altinn.Correspondence.API/Mappers/InitializeCorrespondenceAttachmentMapper.cs Removed RestrictionName from MapToEntity method.
src/Altinn.Correspondence.API/Models/BaseAttachmentExt.cs Removed RestrictionName property from BaseAttachmentExt class.
src/Altinn.Correspondence.Application/GetAttachmentDetails/GetAttachmentDetailsHandler.cs Removed RestrictionName from GetAttachmentDetailsResponse.
src/Altinn.Correspondence.Application/GetAttachmentDetails/GetAttachmentDetailsResponse.cs Removed RestrictionName property from GetAttachmentDetailsResponse class.
src/Altinn.Correspondence.Application/GetAttachmentOverview/GetAttachmentOverviewHandler.cs Removed RestrictionName from GetAttachmentOverviewResponse.
src/Altinn.Correspondence.Application/GetAttachmentOverview/GetAttachmentOverviewResponse.cs Removed RestrictionName property from GetAttachmentOverviewResponse class.
src/Altinn.Correspondence.Core/Models/Entities/AttachmentEntity.cs Removed RestrictionName property from AttachmentEntity class.
src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.Designer.cs Added migration to remove RestrictionName from AttachmentEntity.
src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.cs Migration to drop RestrictionName column from Attachments table.
src/Altinn.Correspondence.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs Updated snapshot to reflect removal of RestrictionName from AttachmentEntity.

Possibly related PRs

Suggested labels

kind/bug, kind/enhancement

Suggested reviewers

  • Ceredron
  • Andreass2

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@CelineTrammi CelineTrammi marked this pull request as ready for review October 29, 2024 14:28
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
altinn-correspondence-postman-collection.json (1)

Multiple instances of restrictionName found in request/response examples

The search results show that restrictionName is still present in multiple request and response examples within the Postman collection. These need to be removed from:

  • Request bodies in the example JSON payloads
  • Response example bodies
  • Form data parameters
🔗 Analysis chain

Line range hint 1-2050: Verify complete removal of RestrictionName

Let's ensure we haven't missed any instances of RestrictionName in the collection.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining instances of RestrictionName in the file
echo "Searching for remaining instances of RestrictionName..."
rg -i "restrictionName" altinn-correspondence-postman-collection.json

Length of output: 48185

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 522084a and 63bdc52.

📒 Files selected for processing (20)
  • Test/Altinn.Correspondence.LoadTests/test_initialize_and_upload_correspondence.js (0 hunks)
  • Test/Altinn.Correspondence.Tests/CorrespondenceControllerTests.cs (0 hunks)
  • Test/Altinn.Correspondence.Tests/Factories/AttachmentBuilder.cs (0 hunks)
  • Test/Altinn.Correspondence.Tests/Factories/CorrespondenceBuilder.cs (0 hunks)
  • Test/Altinn.Correspondence.Tests/Helpers/AttachmentHelper.cs (0 hunks)
  • altinn-correspondence-postman-collection.json (8 hunks)
  • src/Altinn.Correspondence.API/Mappers/AttachmentDetailsMapper.cs (0 hunks)
  • src/Altinn.Correspondence.API/Mappers/AttachmentOverviewMapper.cs (0 hunks)
  • src/Altinn.Correspondence.API/Mappers/CorrespondenceAttachmentMapper.cs (0 hunks)
  • src/Altinn.Correspondence.API/Mappers/InitializeAttachmentMapper.cs (0 hunks)
  • src/Altinn.Correspondence.API/Mappers/InitializeCorrespondenceAttachmentMapper.cs (0 hunks)
  • src/Altinn.Correspondence.API/Models/BaseAttachmentExt.cs (0 hunks)
  • src/Altinn.Correspondence.Application/GetAttachmentDetails/GetAttachmentDetailsHandler.cs (0 hunks)
  • src/Altinn.Correspondence.Application/GetAttachmentDetails/GetAttachmentDetailsResponse.cs (0 hunks)
  • src/Altinn.Correspondence.Application/GetAttachmentOverview/GetAttachmentOverviewHandler.cs (0 hunks)
  • src/Altinn.Correspondence.Application/GetAttachmentOverview/GetAttachmentOverviewResponse.cs (0 hunks)
  • src/Altinn.Correspondence.Core/Models/Entities/AttachmentEntity.cs (0 hunks)
  • src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.Designer.cs (1 hunks)
  • src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.cs (1 hunks)
  • src/Altinn.Correspondence.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs (0 hunks)
💤 Files with no reviewable changes (17)
  • Test/Altinn.Correspondence.LoadTests/test_initialize_and_upload_correspondence.js
  • Test/Altinn.Correspondence.Tests/CorrespondenceControllerTests.cs
  • Test/Altinn.Correspondence.Tests/Factories/AttachmentBuilder.cs
  • Test/Altinn.Correspondence.Tests/Factories/CorrespondenceBuilder.cs
  • Test/Altinn.Correspondence.Tests/Helpers/AttachmentHelper.cs
  • src/Altinn.Correspondence.API/Mappers/AttachmentDetailsMapper.cs
  • src/Altinn.Correspondence.API/Mappers/AttachmentOverviewMapper.cs
  • src/Altinn.Correspondence.API/Mappers/CorrespondenceAttachmentMapper.cs
  • src/Altinn.Correspondence.API/Mappers/InitializeAttachmentMapper.cs
  • src/Altinn.Correspondence.API/Mappers/InitializeCorrespondenceAttachmentMapper.cs
  • src/Altinn.Correspondence.API/Models/BaseAttachmentExt.cs
  • src/Altinn.Correspondence.Application/GetAttachmentDetails/GetAttachmentDetailsHandler.cs
  • src/Altinn.Correspondence.Application/GetAttachmentDetails/GetAttachmentDetailsResponse.cs
  • src/Altinn.Correspondence.Application/GetAttachmentOverview/GetAttachmentOverviewHandler.cs
  • src/Altinn.Correspondence.Application/GetAttachmentOverview/GetAttachmentOverviewResponse.cs
  • src/Altinn.Correspondence.Core/Models/Entities/AttachmentEntity.cs
  • src/Altinn.Correspondence.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs
🔇 Additional comments (12)
src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.cs (3)

8-9: LGTM! Migration class follows naming conventions.

The migration name clearly describes its purpose and follows the standard naming pattern.


20-28: LGTM! Rollback strategy is appropriate.

The Down method properly restores the column with the correct data type and nullability:

  • Column type is 'text' which is suitable for unrestricted string content
  • Nullable is set to true, maintaining data flexibility

11-17: LGTM! Column removal is properly implemented.

The Up method correctly removes the RestrictionName column from the Attachments table in the correspondence schema.

Let's verify that this is the only occurrence of RestrictionName in the database schema:

src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.Designer.cs (2)

395-479: Entity relationships are well-configured.

The entity relationships are properly defined with:

  • Appropriate cascade delete behaviors
  • Clear navigation properties
  • Correct foreign key constraints

1-507: Migration looks correct but verify dependent code.

The migration correctly removes the RestrictionName property while maintaining all entity relationships and constraints. However, consider the following:

Let's verify any remaining usages of RestrictionName in the codebase:

Consider the following for handling the data migration:

  1. Ensure you have a backup of production data before applying this migration
  2. If RestrictionName contained business-critical data, consider archiving it before removal
  3. Update any API documentation to reflect this breaking change
  4. Consider adding a note in the changelog about this breaking change
✅ Verification successful

The search results show that RestrictionName appears only in migration files, which is expected as they represent the historical state of the database schema. There are no references to this property in actual business logic, controllers, or other parts of the codebase. Let's verify this further by searching for any potential usages in models or entities:


Let's try a different approach to find the entity definition:


Property removal is clean and safe to proceed

The verification confirms that:

  1. RestrictionName property is not present in the current AttachmentEntity class definition
  2. All references to RestrictionName exist only in migration history files
  3. No active code depends on this property
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to RestrictionName that might need updating
rg -i "RestrictionName" --type cs

Length of output: 3283


Script:

#!/bin/bash
# Search for AttachmentEntity class definition to verify property removal
ast-grep --pattern 'class AttachmentEntity {
  $$$
}'

Length of output: 55


Script:

#!/bin/bash
# Search for AttachmentEntity class definition using ripgrep with context
rg -l "class AttachmentEntity" | xargs rg -A 20 "class AttachmentEntity"

Length of output: 587

altinn-correspondence-postman-collection.json (7)

1513-1513: LGTM! Initialize Batch Attachment request body correctly excludes RestrictionName

The request body has been updated to remove the RestrictionName field, which aligns with the PR objective.


1673-1673: ⚠️ Potential issue

Remove RestrictionName from Upload response example

The upload response example still includes the restrictionName field which should be removed.

Apply this diff to remove the field:

{
  "dataLocationUrl": "ExternalStorage",
  "dataType": "<string>",
  "expirationTime": "<dateTime>",
  "name": "<string>",
  "sendersReference": "<string>",
  "usageType": "MachineReadable",
  "fileName": "<string>",
  "isEncrypted": "<boolean>",
- "restrictionName": "<string>",
  "checksum": "<string>",
  "attachmentId": "<uuid>",
  "status": "UploadProcessing",
  "statusText": "<string>",
  "statusChanged": "<dateTime>"
}

Likely invalid or redundant comment.


1843-1843: ⚠️ Potential issue

Remove RestrictionName from Overview response example

The overview response example still includes the restrictionName field which should be removed.

Apply this diff to remove the field:

{
  "dataLocationUrl": "ExternalStorage",
  "dataType": "<string>",
  "expirationTime": "<dateTime>",
  "name": "<string>",
  "sendersReference": "<string>",
  "usageType": "MachineReadable",
  "fileName": "<string>",
  "isEncrypted": "<boolean>",
- "restrictionName": "<string>",
  "checksum": "<string>",
  "attachmentId": "<uuid>",
  "status": "UploadProcessing",
  "statusText": "<string>",
  "statusChanged": "<dateTime>"
}

Likely invalid or redundant comment.


1765-1765: ⚠️ Potential issue

Remove RestrictionName from Download response example

The download response example still includes the restrictionName field which should be removed.

Apply this diff to remove the field:

{
  "dataLocationUrl": "ExternalStorage",
  "dataType": "<string>",
  "expirationTime": "<dateTime>",
  "name": "<string>",
  "sendersReference": "<string>",
  "usageType": "MachineReadable",
  "fileName": "<string>",
  "isEncrypted": "<boolean>",
- "restrictionName": "<string>",
  "checksum": "<string>",
  "attachmentId": "<uuid>",
  "status": "UploadProcessing",
  "statusText": "<string>",
  "statusChanged": "<dateTime>"
}

Likely invalid or redundant comment.


2001-2001: ⚠️ Potential issue

Remove RestrictionName from Purge response example

The purge response example still includes the restrictionName field which should be removed.

Apply this diff to remove the field:

{
  "dataLocationUrl": "ExternalStorage",
  "dataType": "<string>",
  "expirationTime": "<dateTime>",
  "name": "<string>",
  "sendersReference": "<string>",
  "usageType": "MachineReadable",
  "fileName": "<string>",
  "isEncrypted": "<boolean>",
- "restrictionName": "<string>",
  "checksum": "<string>",
  "attachmentId": "<uuid>",
  "status": "UploadProcessing",
  "statusText": "<string>",
  "statusChanged": "<dateTime>"
}

Likely invalid or redundant comment.


1551-1551: ⚠️ Potential issue

Remove RestrictionName from Initialize Batch Attachment response example

The response body example still includes the restrictionName field which should be removed to maintain consistency with the PR objective.

Apply this diff to remove the field:

{
  "dataType": "<string>",
  "expirationTime": "<dateTime>",
  "name": "<string>",
  "sendersReference": "<string>",
  "usageType": "HumanReadable",
  "fileName": "<string>",
  "isEncrypted": "<boolean>",
- "restrictionName": "<string>",
  "checksum": "<string>"
}

Likely invalid or redundant comment.


1923-1923: ⚠️ Potential issue

Remove RestrictionName from Details response example

The details response example still includes the restrictionName field which should be removed.

Apply this diff to remove the field:

{
  "dataLocationUrl": "ExternalStorage",
  "dataType": "<string>",
  "expirationTime": "<dateTime>",
  "name": "<string>",
  "sendersReference": "<string>",
  "usageType": "MachineReadable",
  "fileName": "<string>",
  "isEncrypted": "<boolean>",
- "restrictionName": "<string>",
  "checksum": "<string>",
  "attachmentId": "<uuid>",
  "status": "Deleted",
  "statusText": "<string>",
  "statusChanged": "<dateTime>",
  "statusHistory": [
    {
      "status": "Failed",
      "statusText": "<string>",
      "statusChanged": "<dateTime>"
    },
    {
      "status": "Deleted",
      "statusText": "<string>",
      "statusChanged": "<dateTime>"
    }
  ]
}

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.cs (1)

1-30: Consider adding XML documentation.

While the migration's purpose is clear from its name, consider adding XML documentation to describe the business reason for removing this column and any related changes that should be considered during deployment.

 namespace Altinn.Correspondence.Persistence.Migrations
 {
+    /// <summary>
+    /// Migration to remove the RestrictionName column from the Attachments table
+    /// as part of the effort to simplify the attachment data model.
+    /// Related to PR #414 and Issue #410.
+    /// </summary>
     public partial class Remove_RestrictionNameFromAttachmentEntity : Migration
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 522084a and 63bdc52.

📒 Files selected for processing (20)
  • Test/Altinn.Correspondence.LoadTests/test_initialize_and_upload_correspondence.js (0 hunks)
  • Test/Altinn.Correspondence.Tests/CorrespondenceControllerTests.cs (0 hunks)
  • Test/Altinn.Correspondence.Tests/Factories/AttachmentBuilder.cs (0 hunks)
  • Test/Altinn.Correspondence.Tests/Factories/CorrespondenceBuilder.cs (0 hunks)
  • Test/Altinn.Correspondence.Tests/Helpers/AttachmentHelper.cs (0 hunks)
  • altinn-correspondence-postman-collection.json (8 hunks)
  • src/Altinn.Correspondence.API/Mappers/AttachmentDetailsMapper.cs (0 hunks)
  • src/Altinn.Correspondence.API/Mappers/AttachmentOverviewMapper.cs (0 hunks)
  • src/Altinn.Correspondence.API/Mappers/CorrespondenceAttachmentMapper.cs (0 hunks)
  • src/Altinn.Correspondence.API/Mappers/InitializeAttachmentMapper.cs (0 hunks)
  • src/Altinn.Correspondence.API/Mappers/InitializeCorrespondenceAttachmentMapper.cs (0 hunks)
  • src/Altinn.Correspondence.API/Models/BaseAttachmentExt.cs (0 hunks)
  • src/Altinn.Correspondence.Application/GetAttachmentDetails/GetAttachmentDetailsHandler.cs (0 hunks)
  • src/Altinn.Correspondence.Application/GetAttachmentDetails/GetAttachmentDetailsResponse.cs (0 hunks)
  • src/Altinn.Correspondence.Application/GetAttachmentOverview/GetAttachmentOverviewHandler.cs (0 hunks)
  • src/Altinn.Correspondence.Application/GetAttachmentOverview/GetAttachmentOverviewResponse.cs (0 hunks)
  • src/Altinn.Correspondence.Core/Models/Entities/AttachmentEntity.cs (0 hunks)
  • src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.Designer.cs (1 hunks)
  • src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.cs (1 hunks)
  • src/Altinn.Correspondence.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs (0 hunks)
💤 Files with no reviewable changes (17)
  • Test/Altinn.Correspondence.LoadTests/test_initialize_and_upload_correspondence.js
  • Test/Altinn.Correspondence.Tests/CorrespondenceControllerTests.cs
  • Test/Altinn.Correspondence.Tests/Factories/AttachmentBuilder.cs
  • Test/Altinn.Correspondence.Tests/Factories/CorrespondenceBuilder.cs
  • Test/Altinn.Correspondence.Tests/Helpers/AttachmentHelper.cs
  • src/Altinn.Correspondence.API/Mappers/AttachmentDetailsMapper.cs
  • src/Altinn.Correspondence.API/Mappers/AttachmentOverviewMapper.cs
  • src/Altinn.Correspondence.API/Mappers/CorrespondenceAttachmentMapper.cs
  • src/Altinn.Correspondence.API/Mappers/InitializeAttachmentMapper.cs
  • src/Altinn.Correspondence.API/Mappers/InitializeCorrespondenceAttachmentMapper.cs
  • src/Altinn.Correspondence.API/Models/BaseAttachmentExt.cs
  • src/Altinn.Correspondence.Application/GetAttachmentDetails/GetAttachmentDetailsHandler.cs
  • src/Altinn.Correspondence.Application/GetAttachmentDetails/GetAttachmentDetailsResponse.cs
  • src/Altinn.Correspondence.Application/GetAttachmentOverview/GetAttachmentOverviewHandler.cs
  • src/Altinn.Correspondence.Application/GetAttachmentOverview/GetAttachmentOverviewResponse.cs
  • src/Altinn.Correspondence.Core/Models/Entities/AttachmentEntity.cs
  • src/Altinn.Correspondence.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs
✅ Files skipped from review due to trivial changes (1)
  • altinn-correspondence-postman-collection.json
🔇 Additional comments (6)
src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.cs (3)

8-8: LGTM! Migration name follows conventions.

The migration name clearly describes its purpose and follows the standard naming convention.


13-17: LGTM! Up migration is correctly implemented.

The Up migration properly removes the RestrictionName column from the Attachments table in the correspondence schema.


22-28: Verify the column definition in Down migration.

The Down migration looks correct, preserving both the nullable state and text data type. However, let's verify this matches the original column definition.

✅ Verification successful

The Down migration correctly matches the original column definition

Looking at the initial migration (20240814104030_Initial_DB_Setup.cs) that created the RestrictionName column, we can confirm that the Down migration in the current file exactly matches the original definition:

  • Column type: "text"
  • Nullable: true
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for previous migrations that might have defined the RestrictionName column
# to ensure we're using the same data type and nullable state in our Down migration

# Look for migrations containing "RestrictionName" and "Attachments"
rg -l --type cs "RestrictionName.*Attachments|Attachments.*RestrictionName" src/Altinn.Correspondence.Persistence/Migrations/

Length of output: 127


Script:

#!/bin/bash
# Let's try a broader search to find any migrations related to the Attachments table
rg -l "table: \"Attachments\"" src/Altinn.Correspondence.Persistence/Migrations/

# Also search for any reference to RestrictionName in the entire migrations directory
rg "RestrictionName" src/Altinn.Correspondence.Persistence/Migrations/ -A 3 -B 3

Length of output: 19375

src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.Designer.cs (3)

395-423: Relationship configurations are properly defined.

The cascade delete behaviors are correctly configured for AttachmentEntity relationships:

  • One-to-many with AttachmentStatusEntity
  • One-to-many with CorrespondenceAttachmentEntity

This ensures referential integrity and prevents orphaned records.


32-77: Property configurations in AttachmentEntity are well-defined.

The properties have appropriate:

  • Required/optional constraints
  • String length limits
  • Data types

1-507: Migration changes look good and align with PR objectives.

The migration correctly removes the RestrictionName property from AttachmentEntity while maintaining all other properties and relationships. The database schema and configurations are properly defined.

Let's verify that this is the only place where RestrictionName was used:

✅ Verification successful

Let me analyze the search results to verify if the removal of RestrictionName is properly handled.


Migration is correctly implemented and all references are accounted for

The migration properly handles the removal of the RestrictionName column:

  • Up migration drops the column from the Attachments table
  • Down migration adds it back as a nullable text column
  • All other occurrences of RestrictionName are in previous migration snapshots, which is expected and correct
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to RestrictionName
rg -i "RestrictionName" --type cs

Length of output: 3283


Script:

#!/bin/bash
# Let's check the migration file to see how the removal is handled
cat src/Altinn.Correspondence.Persistence/Migrations/20241029141456_Remove_RestrictionNameFromAttachmentEntity.cs

Length of output: 990

Copy link
Collaborator

@Andreass2 Andreass2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be tagged with breaking change

@CelineTrammi CelineTrammi merged commit 9fa181f into main Oct 30, 2024
10 checks passed
@CelineTrammi CelineTrammi deleted the feat/remove-restriction-name branch October 30, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants