Skip to content

BYNT-1372: Actor.id_number migration#122

Merged
cango91 merged 10 commits intobynt-1371-id-number-typesfrom
bynt-1372-actor-idnumber-migration
Jun 26, 2025
Merged

BYNT-1372: Actor.id_number migration#122
cango91 merged 10 commits intobynt-1371-id-number-typesfrom
bynt-1372-actor-idnumber-migration

Conversation

@cango91
Copy link
Contributor

@cango91 cango91 commented Jun 25, 2025

Jira Issue

  1. BYNT-1372

Description

  • 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

Checklist

  • Tests added/updated
  • Documentation updated (if needed)
  • New strings prepared for translations

API Changes (if applicable)

  • Permissions checked
  • Endpoint tests added

Additional Notes

[Any other relevant information]

cango91 added 4 commits June 23, 2025 21:29
- 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
@cango91 cango91 requested a review from Copilot June 25, 2025 18:19
Copy link

Copilot AI left a comment

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 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.

cango91 and others added 2 commits June 25, 2025 14:28
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>
@cango91 cango91 marked this pull request as ready for review June 25, 2025 19:34
@cango91 cango91 self-assigned this Jun 25, 2025
@cango91 cango91 merged commit af56642 into bynt-1371-id-number-types Jun 26, 2025
2 of 3 checks passed
@cango91 cango91 deleted the bynt-1372-actor-idnumber-migration branch June 26, 2025 18:09
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.
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