Skip to content

Feature/update id columns#148

Merged
bodynar merged 3 commits into
developfrom
feature/update_id_columns
Mar 22, 2026
Merged

Feature/update id columns#148
bodynar merged 3 commits into
developfrom
feature/update_id_columns

Conversation

@bodynar

@bodynar bodynar commented Mar 21, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the MAS.Payments domain and API contract from long-based identifiers to Guid-based identifiers, aligning DTOs/commands/controllers with the new key type and adding an EF Core migration to convert existing PostgreSQL tables.

Changes:

  • Switched request/response/query/command ID fields from long/long? to Guid/Guid? across Payments/Measurements/User flows.
  • Updated persistence layer (base Entity, repositories, EF model config, snapshot) to use Guid primary/foreign keys and client-side ID generation.
  • Added a data-migrating EF Core migration to convert existing PK/FK columns from bigint to uuid.

Reviewed changes

Copilot reviewed 81 out of 82 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Queries/User/GetUserSettings/GetUserSettingsQueryResult.cs Update settings DTO Id to Guid.
Queries/User/GetUserNotifications/GetUserNotificationsQueryResult.cs Update notification DTO Id to nullable Guid.
Queries/Payments/GetStatistics/GetPaymentStatisticsResponse/PaymentTypeStatisticsItem.cs Update statistics item PaymentTypeId to Guid.
Queries/Payments/GetStatistics/GetPaymentStatisticsQuery.cs Update filter PaymentTypeId to nullable Guid.
Queries/Payments/GetPayments/GetPaymentsResponse.cs Update payment response Id/PaymentTypeId to Guid.
Queries/Payments/GetPayments/GetPaymentsQuery.cs Update query filter PaymentTypeId to nullable Guid.
Queries/Payments/GetPaymentTypes/GetPaymentTypesResponse.cs Update payment type list response Id to Guid.
Queries/Payments/GetPaymentType/GetPaymentTypeResponse.cs Update payment type response Id to Guid.
Queries/Payments/GetPaymentType/GetPaymentTypeQuery.cs Update query Id to Guid.
Queries/Payments/GetPayment/GetPaymentResponse.cs Update payment response Id/PaymentTypeId to Guid.
Queries/Payments/GetPayment/GetPaymentQuery.cs Update query Id to Guid.
Queries/PaymentGroups/GetPaymentGroups/GetPaymentGroupsResponse.cs Update payment group list response Id to Guid.
Queries/PaymentGroups/GetPaymentGroup/GetPaymentGroupResponse.cs Update payment group + nested payment DTO IDs to Guid.
Queries/PaymentGroups/GetPaymentGroup/GetPaymentGroupQuery.cs Update query Id to Guid.
Queries/PaymentFiles/GetPaymentFiles/GetPaymentFilesResponse.cs Update file response Id/linked entity IDs to Guid.
Queries/PaymentFiles/GetPaymentFile/GetPaymentFileQuery.cs Update query Id to Guid.
Queries/Measurements/GetStatistics/GetMeasurementStatisticsQueryResponse/MeasurementTypeStatisticsItem.cs Update statistics item MeasurementTypeId to Guid.
Queries/Measurements/GetStatistics/GetMeasurementStatisticsQuery.cs Update filter MeasurementTypeId to nullable Guid.
Queries/Measurements/GetSiblingMeasurement/GetSiblingMeasurementQuery.cs Update measurement type key to Guid and adjust validation.
Queries/Measurements/GetMeterMeasurements/GetMeterMeasurementsQueryResponse.cs Update measurement response Id/type id to Guid.
Queries/Measurements/GetMeterMeasurements/GetMeterMeasurementsQuery.cs Update filter MeterMeasurementTypeId to nullable Guid.
Queries/Measurements/GetMeterMeasurementTypes/GetMeterMeasurementTypesResponse.cs Update measurement type response IDs to Guid.
Queries/Measurements/GetMeasurementType/GetMeterMeasurementTypeResponse.cs Update measurement type response IDs to Guid.
Queries/Measurements/GetMeasurementType/GetMeterMeasurementTypeQuery.cs Update query Id to Guid.
Queries/Measurements/GetMeasurement/GetMeterMeasurementResponse.cs Update measurement response Id/type id to Guid.
Queries/Measurements/GetMeasurement/GetMeterMeasurementQuery.cs Update query Id to Guid.
Queries/Measurements/GetGroupedMeterMeasurements/GetGroupedMeterMeasurementsResponse.cs Update grouped measurement DTO IDs to Guid.
Queries/Measurements/GetGroupedMeterMeasurements/GetGroupedMeterMeasurementsQuery.cs Update filter MeterMeasurementTypeId to nullable Guid.
Models/User/Request/UpdateUserSettingsRequest.cs Update request Id to Guid.
Models/Statistics/GetPaymentsStatisticsRequest.cs Update request filter PaymentTypeId to nullable Guid.
Models/Statistics/GetMeasurementStatisticsRequest.cs Update request filter MeasurementTypeId to nullable Guid.
Models/PaymentGroup/UpdatePaymentGroupRequest.cs Update request Id to Guid.
Models/Payment/UpdatePaymentTypeRequest.cs Update request Id to Guid.
Models/Payment/UpdatePaymentRequest.cs Update request IDs to Guid.
Models/Payment/GetPaymentsRequest.cs Update request filter PaymentTypeId to nullable Guid.
Models/Payment/AddPaymentRequest.cs Update request PaymentTypeId to Guid.
Models/Payment/AddPaymentGroupRequest.cs Update request item PaymentTypeId to Guid.
Models/Measurement/UpdateMeterMeasurementTypeRequest.cs Update request IDs to Guid.
Models/Measurement/UpdateMeterMeasurementRequest.cs Update request IDs to Guid.
Models/Measurement/GetMeterMeasurementRequest.cs Update request filter MeasurementTypeId to nullable Guid.
Models/Measurement/AddMeterMeasurementTypeRequest.cs Update request PaymentTypeId to Guid.
Models/Measurement/AddMeasurementGroupRequest.cs Update request item TypeId to Guid.
Models/DeleteRecordsRequest.cs Update bulk delete IDs to IEnumerable<Guid>.
Models/DeleteRecordRequest.cs Update delete request Id to Guid.
Migrations/DataBaseContextModelSnapshot.cs Update EF snapshot to uuid keys and seed Guid.
Migrations/20260321211036_SwitchToGuidIds.cs Add migration converting bigint PK/FKs to uuid with data mapping.
Migrations/20260321211036_SwitchToGuidIds.Designer.cs Add designer model for Guid-key schema.
MAS.Payments.csproj Enable implicit usings.
Infrastructure/Exceptions/EntityNotFoundException.cs Update exception to accept Guid id.
DataBase/Specifications/Common/IdIn.cs Update common specification key list to Guid.
DataBase/Models/PaymentFile.cs Update FK properties to nullable Guid.
DataBase/Models/Payment.cs Update FK properties to Guid.
DataBase/Models/MeterMeasurementType.cs Update FK property to Guid.
DataBase/Models/MeterMeasurement.cs Update FK property to Guid.
DataBase/DataBaseContext.cs Configure non-generated Guid keys + generate Ids in SaveChangesAsync + update seed.
DataBase/DataAccess/Implementations/Repository.cs Update repository CRUD methods to use Guid keys.
DataBase/DataAccess/IRepository.cs Update repository interface to use Guid keys.
DataBase/DataAccess/Entity.cs Switch base entity Id from long to Guid.
Controllers/UserApiController.cs Update hide notifications endpoint to accept/return Guid IDs.
Controllers/PaymentFileApiController.cs Update file upload/get/view endpoints to use Guid IDs.
Controllers/PaymentApiController.cs Update get-by-id endpoints to accept Guid IDs.
Controllers/MeterMeasurementApiController.cs Update get-by-id endpoints to accept Guid IDs.
Commands/User/HideUserNotification/HideUserNotificationCommand.cs Update command IDs to Guid.
Commands/PaymentType/UpdatePaymentType/UpdatePaymentTypeCommand.cs Update command Id to Guid.
Commands/PaymentType/DeletePaymentType/DeletePaymentTypeCommand.cs Update command id to Guid.
Commands/PaymentGroup/UpdatePaymentGroup/UpdatePaymentGroupCommand.cs Update command Id to Guid.
Commands/PaymentGroup/DeletePaymentGroup/DeletePaymentGroupCommand.cs Update command id to Guid.
Commands/PaymentFile/UploadPaymentFile/UploadPaymentFileCommand.cs Update link IDs to nullable Guid.
Commands/PaymentFile/DeletePaymentFiles/DeletePaymentFilesCommand.cs Update bulk delete IDs to Guid.
Commands/PaymentFile/DeletePaymentFile/DeletePaymentFileCommand.cs Update delete id to Guid.
Commands/Payment/UpdatePayment/UpdatePaymentCommand.cs Update command IDs to Guid.
Commands/Payment/DeletePayment/DeletePaymentCommand.cs Update delete id to Guid.
Commands/Payment/AddPayment/AddPaymentCommand.cs Update PaymentTypeId to Guid.
Commands/Payment/AddGroup/PaymentGroupItem.cs Update item PaymentTypeId to Guid.
Commands/MeterMeasurementType/UpdateMeterMeasurementType/UpdateMeterMeasurementTypeCommand.cs Update command IDs to Guid.
Commands/MeterMeasurementType/DeleteMeterMeasurementType/DeleteMeterMeasurementTypeCommand.cs Update delete id to Guid.
Commands/MeterMeasurementType/AddMeterMeasurementType/AddMeterMeasurementTypeCommand.cs Update PaymentTypeId to Guid.
Commands/MeterMeasurement/UpdateMeterMeasurement/UpdateMeterMeasurementCommandHandler.cs Fix/update local old type id handling for Guid.
Commands/MeterMeasurement/UpdateMeterMeasurement/UpdateMeterMeasurementCommand.cs Update command IDs to Guid.
Commands/MeterMeasurement/DeleteMeterMeasurement/DeleteMeterMeasurementCommand.cs Update delete id to Guid.
Commands/MeterMeasurement/AddGroup/MeasurementGroup.cs Update group item type id to Guid.
Commands/MeterMeasurement/AddGroup/AddMeasurementGroupCommandHandler.cs Update duplicate-type HashSet to Guid.
Files not reviewed (1)
  • Migrations/20260321211036_SwitchToGuidIds.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to +27
migrationBuilder.Sql("""
ALTER TABLE "PaymentType" ADD COLUMN "temp_new_id" uuid NOT NULL DEFAULT gen_random_uuid();
ALTER TABLE "PaymentGroup" ADD COLUMN "temp_new_id" uuid NOT NULL DEFAULT gen_random_uuid();
ALTER TABLE "Payment" ADD COLUMN "temp_new_id" uuid NOT NULL DEFAULT gen_random_uuid();
ALTER TABLE "MeterMeasurementType" ADD COLUMN "temp_new_id" uuid NOT NULL DEFAULT gen_random_uuid();
ALTER TABLE "MeterMeasurement" ADD COLUMN "temp_new_id" uuid NOT NULL DEFAULT gen_random_uuid();
ALTER TABLE "PaymentFile" ADD COLUMN "temp_new_id" uuid NOT NULL DEFAULT gen_random_uuid();
ALTER TABLE "UserSetting" ADD COLUMN "temp_new_id" uuid NOT NULL DEFAULT gen_random_uuid();
ALTER TABLE "UserNotification" ADD COLUMN "temp_new_id" uuid NOT NULL DEFAULT gen_random_uuid();
""");

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

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

The migration relies on PostgreSQL function gen_random_uuid() when adding temp UUID columns. This function requires the pgcrypto extension; on a fresh or existing DB without it, the migration will fail. Add a CREATE EXTENSION IF NOT EXISTS pgcrypto; step (before STEP 1), or switch to a UUID generator that you explicitly enable in migrations (e.g., uuid-ossp).

Copilot uses AI. Check for mistakes.
Comment thread Migrations/20260321211036_SwitchToGuidIds.cs Outdated
Comment thread Migrations/20260321211036_SwitchToGuidIds.cs
@bodynar bodynar merged commit 56b539c into develop Mar 22, 2026
1 check passed
@bodynar bodynar deleted the feature/update_id_columns branch March 22, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants