Management Command to Sync Issued Date for User Credentials#267
Open
zandre-eng wants to merge 1 commit into
Open
Management Command to Sync Issued Date for User Credentials#267zandre-eng wants to merge 1 commit into
zandre-eng wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Technical Summary
Link to ticket here
This is a release path 1 feature — Improvements to existing features & quick wins.
Builds on the
ze/credential-issued-datebase branch, which added a per-userUserCredential.created_at. Because that column was added withauto_now_add, existing rows were stamped with the migration run time rather than the real issue date, so this adds async_usercredential_created_atmanagement command to backfill the accurate per-user dates from a Connect prod export ofissued_on. It optionally (--fix-issuer) also repoints credentials that were historically mis-attributed to the staging issuer (Connect prod pushed them via the generic/staging client) onto the production issuer, using a split-per-user approach so staging-only holders are preserved.Logging and monitoring
The command is a dry run by default and prints a reconciliation summary before any writes — counts of
to_update,already_correct,no_pid_match,pid_unmatched_by_export, and, with--fix-issuer, issuer repoints and the number of staging credentials left orphaned. It is a one-off operational tool and adds no runtime logging.Safety Assurance
Safety story
This is an opt-in management command, not runtime code, so it has no effect until deliberately run. It defaults to a dry run, requires both
--applyand an interactiveyconfirmation (with--no-inputfor scripted runs), executes within a single transaction, and is idempotent on re-run. Matching is restricted to CONNECT-issued credentials on the join key(username, type, level, slug).--fix-issuercreates production-issuer credentials while leaving staging credentials intact and never deletes data — orphaned staging credentials are only reported.Automated test coverage
Tests exercise the command end-to-end: loading/parsing the export file, dry-run vs apply, the matching rules (CONNECT-only, int/string opportunity-id coercion), skip/already-correct/no-match/unmatched reporting, bad
issued_onhandling, the confirmation prompt (apply vs abort), input validation, and the optional issuer repointing including the shared-credential split and idempotency.QA Plan
No QA planned for this change.
Labels & Review