diff --git a/src/digid_eherkenning_oidc_generics/migrations/0002_openidconnectdigidconfig_oidc_token_use_basic_auth_and_more.py b/src/digid_eherkenning_oidc_generics/migrations/0002_openidconnectdigidconfig_oidc_token_use_basic_auth_and_more.py index a17b5b3f11..5cd230faa7 100644 --- a/src/digid_eherkenning_oidc_generics/migrations/0002_openidconnectdigidconfig_oidc_token_use_basic_auth_and_more.py +++ b/src/digid_eherkenning_oidc_generics/migrations/0002_openidconnectdigidconfig_oidc_token_use_basic_auth_and_more.py @@ -1,6 +1,6 @@ # Generated by Django 4.2.11 on 2024-07-07 13:44 -from django.db import migrations, models +from django.db import migrations class Migration(migrations.Migration): @@ -9,23 +9,15 @@ class Migration(migrations.Migration): ("digid_eherkenning_oidc_generics_legacy", "0001_legacy"), ] - operations = [ - migrations.AddField( - model_name="openidconnectdigidconfig", - name="oidc_token_use_basic_auth", - field=models.BooleanField( - default=False, - help_text="If enabled, the client ID and secret are sent in the HTTP Basic auth header when obtaining the access token. Otherwise, they are sent in the request body.", - verbose_name="Use Basic auth for token endpoint", - ), - ), - migrations.AddField( - model_name="openidconnecteherkenningconfig", - name="oidc_token_use_basic_auth", - field=models.BooleanField( - default=False, - help_text="If enabled, the client ID and secret are sent in the HTTP Basic auth header when obtaining the access token. Otherwise, they are sent in the request body.", - verbose_name="Use Basic auth for token endpoint", - ), - ), - ] + # models have the wrong db_table associated + query1 = """ + ALTER TABLE "digid_eherkenning_oidc_generics_legacy_openidconnectdigidconfig" ADD COLUMN "oidc_token_use_basic_auth" boolean DEFAULT false NOT NULL; + ALTER TABLE "digid_eherkenning_oidc_generics_legacy_openidconnectdigidconfig" ALTER COLUMN "oidc_token_use_basic_auth" DROP DEFAULT; + """ + + query2 = """ + ALTER TABLE "digid_eherkenning_oidc_generics_legacy_openidconnecteherkenningconfig" ADD COLUMN "oidc_token_use_basic_auth" boolean DEFAULT false NOT NULL; + ALTER TABLE "digid_eherkenning_oidc_generics_legacy_openidconnecteherkenningconfig" ALTER COLUMN "oidc_token_use_basic_auth" DROP DEFAULT; + """ + + operations = [migrations.RunSQL(query1), migrations.RunSQL(query2)] diff --git a/src/digid_eherkenning_oidc_generics/migrations/0003_alter_openidconnectdigidconfig_oidc_exempt_urls_and_more.py b/src/digid_eherkenning_oidc_generics/migrations/0003_alter_openidconnectdigidconfig_oidc_exempt_urls_and_more.py index 7eea722a3b..232829387c 100644 --- a/src/digid_eherkenning_oidc_generics/migrations/0003_alter_openidconnectdigidconfig_oidc_exempt_urls_and_more.py +++ b/src/digid_eherkenning_oidc_generics/migrations/0003_alter_openidconnectdigidconfig_oidc_exempt_urls_and_more.py @@ -36,4 +36,22 @@ class Migration(migrations.Migration): verbose_name="URLs exempt from session renewal", ), ), + migrations.AddField( + model_name="openidconnectdigidconfig", + name="oidc_token_use_basic_auth", + field=models.BooleanField( + default=False, + help_text="If enabled, the client ID and secret are sent in the HTTP Basic auth header when obtaining the access token. Otherwise, they are sent in the request body.", + verbose_name="Use Basic auth for token endpoint", + ), + ), + migrations.AddField( + model_name="openidconnecteherkenningconfig", + name="oidc_token_use_basic_auth", + field=models.BooleanField( + default=False, + help_text="If enabled, the client ID and secret are sent in the HTTP Basic auth header when obtaining the access token. Otherwise, they are sent in the request body.", + verbose_name="Use Basic auth for token endpoint", + ), + ), ] diff --git a/src/digid_eherkenning_oidc_generics/migrations/0003_alter_openidconnectdigidconfig_table_and_more.py b/src/digid_eherkenning_oidc_generics/migrations/0003_alter_openidconnectdigidconfig_table_and_more.py index 11647f6782..57c7512465 100644 --- a/src/digid_eherkenning_oidc_generics/migrations/0003_alter_openidconnectdigidconfig_table_and_more.py +++ b/src/digid_eherkenning_oidc_generics/migrations/0003_alter_openidconnectdigidconfig_table_and_more.py @@ -31,3 +31,17 @@ class Migration(migrations.Migration): table="digid_eherkenning_oidc_generics_legacy_openidconnecteherkenningconfig", ), ] + + # models have the wrong db_table associated + query1 = """ + ALTER TABLE "digid_eherkenning_oidc_generics_openidconnectdigidconfig" + RENAME TO "digid_eherkenning_oidc_generics_legacy_openidconnectdigidconfig"; + """ + + query2 = """ + ALTER TABLE "digid_eherkenning_oidc_generics_openidconnecteherkenningconfig" + RENAME TO "digid_eherkenning_oidc_generics_legacy_openidconnecteherkenningconfig"; + """ + + operations = [migrations.RunSQL(query1), migrations.RunSQL(query2)] + operations = [] diff --git a/src/digid_eherkenning_oidc_generics/migrations/0004_alter_openidconnectdigidconfig_table_and_more.py b/src/digid_eherkenning_oidc_generics/migrations/0004_alter_openidconnectdigidconfig_table_and_more.py index b6ef0bbd52..bbc73aca5f 100644 --- a/src/digid_eherkenning_oidc_generics/migrations/0004_alter_openidconnectdigidconfig_table_and_more.py +++ b/src/digid_eherkenning_oidc_generics/migrations/0004_alter_openidconnectdigidconfig_table_and_more.py @@ -12,13 +12,15 @@ class Migration(migrations.Migration): ), ] - operations = [ - migrations.AlterModelTable( - name="openidconnectdigidconfig", - table="digid_eherkenning_oidc_generics_openidconnectdigidconfig", - ), - migrations.AlterModelTable( - name="openidconnecteherkenningconfig", - table="digid_eherkenning_oidc_generics_openidconnecteherkenningconfig", - ), - ] + # models have the wrong db_table associated + query1 = """ + ALTER TABLE "digid_eherkenning_oidc_generics_openidconnectdigidconfig" + RENAME TO "digid_eherkenning_oidc_generics_legacy_openidconnectdigidconfig"; + """ + + query2 = """ + ALTER TABLE "digid_eherkenning_oidc_generics_openidconnecteherkenningconfig" + RENAME TO "digid_eherkenning_oidc_generics_legacy_openidconnecteherkenningconfig"; + """ + + operations = [migrations.RunSQL(query1), migrations.RunSQL(query2)] diff --git a/src/digid_eherkenning_oidc_generics/migrations/0004_delete_openidconnectdigidconfig_and_more.py b/src/digid_eherkenning_oidc_generics/migrations/0004_delete_openidconnectdigidconfig_and_more.py index ded44e4c4e..cff000a60e 100644 --- a/src/digid_eherkenning_oidc_generics/migrations/0004_delete_openidconnectdigidconfig_and_more.py +++ b/src/digid_eherkenning_oidc_generics/migrations/0004_delete_openidconnectdigidconfig_and_more.py @@ -16,11 +16,13 @@ class Migration(migrations.Migration): ), ] - operations = [ - migrations.DeleteModel( - name="OpenIDConnectDigiDConfig", - ), - migrations.DeleteModel( - name="OpenIDConnectEHerkenningConfig", - ), - ] + # models have the wrong db_table associated + query1 = """ + DROP TABLE "digid_eherkenning_oidc_generics_legacy_openidconnectdigidconfig" CASCADE; + """ + + query2 = """ + DROP TABLE "digid_eherkenning_oidc_generics_legacy_openidconnecteherkenningconfig" CASCADE; + """ + + operations = [migrations.RunSQL(query1), migrations.RunSQL(query2)] diff --git a/src/open_inwoner/accounts/migrations/0076_copy_legacy_oidc_digid_eh_configs.py b/src/open_inwoner/accounts/migrations/0076_copy_legacy_oidc_digid_eh_configs.py index 9b6827729b..6cbc8c23cf 100644 --- a/src/open_inwoner/accounts/migrations/0076_copy_legacy_oidc_digid_eh_configs.py +++ b/src/open_inwoner/accounts/migrations/0076_copy_legacy_oidc_digid_eh_configs.py @@ -41,6 +41,14 @@ def forwards(apps, _): "OpenIDConnectEHerkenningConfig", ) + # models have the wrong db_table associated + OpenIDConnectDigiDConfig.objects.model._meta.db_table = ( + "digid_eherkenning_oidc_generics_legacy_openidconnectdigidconfig" + ) + OpenIDConnectEHerkenningConfig.objects.model._meta.db_table = ( + "digid_eherkenning_oidc_generics_legacy_openidconnecteherkenningconfig" + ) + # new models DigiDConfig = apps.get_model( "digid_eherkenning_oidc_generics", @@ -54,13 +62,13 @@ def forwards(apps, _): digid_create_kwargs = { field_name: getattr(legacy_digid, field_name) for field_name in SHARED_FIELDS - } | {"bsn_claim": legacy_digid.identifier_claim_name} + } | {"bsn_claim": [legacy_digid.identifier_claim_name]} DigiDConfig.objects.create(**digid_create_kwargs) if legacy_eh := OpenIDConnectEHerkenningConfig.objects.first(): eh_create_kwargs = { field_name: getattr(legacy_eh, field_name) for field_name in SHARED_FIELDS - } | {"legal_subject_claim": legacy_eh.identifier_claim_name} + } | {"legal_subject_claim": [legacy_eh.identifier_claim_name]} EHerkenningConfig.objects.create(**eh_create_kwargs)