-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(model): move scope and claim config to EligibilityVerifier
- Loading branch information
Showing
5 changed files
with
106 additions
and
32 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
benefits/core/migrations/0019_refactor_idg_config_eligibilityverifier.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Generated by Django 5.0.6 on 2024-08-07 19:24 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def migrate_data(apps, schema_editor): | ||
# This shouldn't be needed since we can get scope and claim from EligibilityVerifier.claims_provider | ||
# but it's here temporarily in case it's needed | ||
# ClaimsProvider = apps.get_model("core", "ClaimsProvider") | ||
EligibilityVerifier = apps.get_model("core", "EligibilityVerifier") | ||
|
||
for verifier in EligibilityVerifier.objects.all(): | ||
# The data migration is not working with | ||
# verifier.claims_scope = ClaimsProvider.objects.filter(id=verifier.claims_provider.id).scope | ||
# or with | ||
# verifier.claims_scope = verifier.claims_provider.scope | ||
# the code below is a placeholder for troubleshooting | ||
verifier.claims_scope = "claims_scope" | ||
# To migrate claim data, repeat the code that is used above using `claim` instead of `scope` | ||
verifier.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("core", "0018_rename_eligibility_api_fields"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="eligibilityverifier", | ||
name="claims_claim", | ||
field=models.TextField( | ||
blank=True, help_text="The name of the claim (name/value pair) that is used to verify eligibility", null=True | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="eligibilityverifier", | ||
name="claims_scope", | ||
field=models.TextField( | ||
blank=True, | ||
help_text="A space-separated list of identifiers used to specify what access privileges are being requested", | ||
null=True, | ||
), | ||
), | ||
migrations.RunPython(migrate_data), | ||
migrations.RemoveField( | ||
model_name="claimsprovider", | ||
name="claim", | ||
), | ||
migrations.RemoveField( | ||
model_name="claimsprovider", | ||
name="scope", | ||
), | ||
] |
This file contains 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
This file contains 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
This file contains 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
This file contains 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