BYNT-1372: Actor.id_number migration#122
Merged
cango91 merged 10 commits intobynt-1371-id-number-typesfrom Jun 26, 2025
Merged
Conversation
- Add migration to migrate Actor.id_number to JSONB array - Add test script to verify data integrity - Modify DELETE IDNumberType endpoint to check for references in Actor.id_number - Add database constraints to ensure data integrity
- Add flatten_id_numbers() method to Actor model that converts JSONB id_number array to flattened dict - Retrieves IDNumberType titles and handles duplicates with _1, _2 suffixes - Integrate flattened ID numbers into CSV export via to_csv_dict() - Remove strict database constraints on id_number JSONB structure and foreign key validation - Update ActorFactory to use proper lazy attribute for id_number generation - Add IDNumberType import to Actor model
- Create validate_actor_id_number() PostgreSQL function that validates JSONB array elements - Add check constraint ensuring each id_number element has string 'type' and 'number' keys - Use DDL events to create function before table creation for both fresh installs and migrations - Includes function in migration script for existing database compatibility
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the Actor.id_number field from a string to a JSONB array format and updates associated tests, queries, and endpoints to support the new structure. Key changes include:
- Migration scripts and DDL to convert and validate Actor.id_number data.
- Updates to tests, factories, and Pydantic models to use the new JSONB array structure.
- Modifications to the DELETE endpoint and search queries to correctly handle the JSONB id_number values.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/models/admin.py | Updated ActorItemMode3Model to use a JSONB list for id_number. |
| tests/factories.py | Replaced the Faker-based id_number generator with a lazy attribute returning a JSONB array. |
| tests/admin/test_id_number_types.py | Adjusted imports and tests to work with the new id_number structure. |
| enferno/utils/search_utils.py | Updated query logic to search within the JSONB array in Actor.id_number. |
| enferno/migrations/20250623_184016_test_actor_id_number_migration_data_integrity.sql | Added SQL tests to verify migration data integrity for id_number. |
| enferno/migrations/20250623_184016_actor_id_number_migration.sql | Migration script converting id_number from string to JSONB array and adding constraints. |
| enferno/admin/views.py | Modified DELETE IDNumberType endpoint to check for references in Actor.id_number. |
| enferno/admin/validation/models.py | Updated validation model to reflect the new JSONB array type for id_number. |
| enferno/admin/models/Actor.py | Changed the id_number column type and updated JSON serialization/deserialization and flattening logic with new DDL events. |
introduce caching the IDNumberType information or performing a bulk query to reduce potential overhead in flatten method. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
level09
added a commit
that referenced
this pull request
Mar 2, 2026
…lp (#273) ## Summary - **yt-dlp**: bump to `>=2026.2.21` to fix high-severity arbitrary command injection via `--netrc-cmd` (Dependabot alert #126) - **extraction.py**: replace raw `str(e)` in error responses with generic messages to prevent internal exception leakage to API clients (CodeQL alert #132) - **app.py**: replace substring check on `MAPS_API_ENDPOINT` with `urlparse` hostname check to prevent crafted URLs from bypassing CSP allowlist (CodeQL alert #122) ## Notes All three endpoints are behind authentication, but defense-in-depth applies. Exception strings are still logged in full server-side.
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.
Jira Issue
Description
Checklist
API Changes (if applicable)
Additional Notes
[Any other relevant information]