-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat(soft-delete): implement soft delete for PaymentOrder and LockPay… #409
base: main
Are you sure you want to change the base?
feat(soft-delete): implement soft delete for PaymentOrder and LockPay… #409
Conversation
…mentOrder - Created SoftDeleteMixin in schema/mixins.go following Ent documentation for soft delete. - Added SoftDeleteMixin to LockPaymentOrder and PaymentOrder schemas. - Updated PaymentOrder edge in SenderProfile to use entsql.Cascade for proper deletion handling. - Added SkipSoftDelete context utility function to conditionally bypass soft delete logic.
@Fidel-wole Please edit your PR description so that issue #407 is not closed. |
@Fidel-wole thanks for the PR, could you resolve the issue with the issue that the PR is closing. |
Ok will do that |
ent/schema/mixins.go
Outdated
type SoftDeleteMixin struct { | ||
mixin.Schema | ||
} | ||
|
||
// Fields of the SoftDeleteMixin. | ||
func (SoftDeleteMixin) Fields() []ent.Field { | ||
return []ent.Field{ | ||
field.Time("deleted_at"). | ||
Optional(). | ||
Nillable(), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you copy all the mixin code that's here? https://entgo.io/docs/interceptors/#soft-delete
the only change should be "delete_time" to "deleted_at"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok sir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fidel-wole can you ask under "Aggregator" topic in the dev community https://t.me/+Stx-wLOdj49iNDM0
utils/utils.go
Outdated
|
||
type contextKey string | ||
|
||
const skipSoftDeleteKey contextKey = "skipSoftDelete" | ||
|
||
// SkipSoftDelete adds a context value to skip soft delete logic. | ||
func SkipSoftDelete(ctx context.Context) context.Context { | ||
return context.WithValue(ctx, skipSoftDeleteKey, true) | ||
} | ||
|
||
// IsSkipSoftDelete returns true if the context indicates that soft delete should be skipped. | ||
func IsSkipSoftDelete(ctx context.Context) bool { | ||
val := ctx.Value(skipSoftDeleteKey) | ||
if val != nil { | ||
return val.(bool) | ||
} | ||
return false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these aren't needed... SkipSoftDelete is already be in the mixin.go
snippet from ent docs
Hi @Fidel-wole, any luck on this? |
…pdate early access logic
…nt-based early access handling
…r.go to match main branch
…tion fields and adjusting early access logic in auth
…ies and improve error messaging
- Modify ProviderOrderToken schema to support multi-currency configuration - Add temporary comments for future schema cleanup - Remove unique constraints and indexes temporarily - Adjust edges and fields to support upcoming multi-currency implementation
…pport - Rename database edges and columns to be more descriptive and consistent - Update schema, query, and mutation files to reflect new naming conventions - Modify references to and to and - Adjust foreign key and index names to match new schema structure - Remove commented-out code and temporary TODO comments git rebase --continue
- Enhance token rate parsing with more robust validation - Add detailed logging for invalid provider data - Validate token symbol, order amount, and rate constraints - Improve error handling and skip invalid rate entries - Refactor GetTokenRateFromQueue to handle multi-part provider data
- Enhance migration scripts for provider order tokens with careful data population - Update unique index for provider order tokens to remove network column - Add robust handling for potential duplicate entries during migration - Modify schema generation to reflect new multi-currency relationships - Implement step-by-step migration strategy with nullable columns and data updates
- Remove unnecessary fmt.Println debug statements in profile controller - Update provider test case to include currency parameter in order request - Replace fmt.Println with logger.Infof in tasks package for better logging
- Add currency parameter to all test payloads in provider test suite - Modify test request URLs to include currency filter - Ensure consistent testing of multi-currency support in provider endpoints
- Uncomment and activate RateLimitMiddleware in router configuration - Improve API request handling with rate limiting protection
- Add token symbol deduplication to avoid redundant rate calculations - Skip processing of repeated token symbols within the same provider - Improve efficiency of priority queue creation for buckets - Maintain existing error handling and logging mechanisms
… method - Replace direct calls to getInstitutionByCode with a new utility function GetInstitutionByCode in the utils package. - Remove the old getInstitutionByCode method from IndexerService to streamline code and improve maintainability. - Update references in IndexerService and OrderEVM to utilize the new utility function for fetching institution data.
- Introduce new document verification methods for Nigeria, Kenya, Ghana, and South Africa. - Standardize verification method to doc_verification for various ID types across these countries. - Enhance support for identity verification by including additional ID types such as TRAVEL_DOC and RESIDENT_ID.
Signed-off-by: superman <[email protected]>
Signed-off-by: od-hunter <[email protected]>
…mentOrder - Created SoftDeleteMixin in schema/mixins.go following Ent documentation for soft delete. - Added SoftDeleteMixin to LockPaymentOrder and PaymentOrder schemas. - Updated PaymentOrder edge in SenderProfile to use entsql.Cascade for proper deletion handling. - Added SkipSoftDelete context utility function to conditionally bypass soft delete logic.
…riorityQueueService
Soft Delete Implementation for PaymentOrder
Summary
Description
This PR introduces soft delete functionality for PaymentOrder and LockPaymentOrder, ensuring that deleted records are retained while being excluded from queries. The update aligns with Ent’s recommended approach, enhancing data integrity and traceability.
Key changes and rationale:
Soft delete implementation: Prevents permanent loss of data while allowing safe deletions.
Cascade deletion fix: Ensures dependent entities in SenderProfile are correctly handled.
Bypass option: Introduces SkipSoftDelete to enable scenarios where soft delete logic should be skipped (e.g., admin overrides).
These changes improve system reliability and maintainability without introducing breaking changes.
References
Closes #401
By submitting this PR, I acknowledge and agree to Paycrest’s Contributor Code of Conduct and Contribution Guide.