From aae308f405a9473c235caa0d6d2d5c4272e70774 Mon Sep 17 00:00:00 2001 From: Saksham Date: Wed, 1 Jul 2026 11:29:00 +0200 Subject: [PATCH] chore(migration): make theses migration optional --- .../upgrade_scripts/migrate_13_0_to_14_0.py | 21 ++++++++++++++++--- tests/test_migrate_13_0_to_14_0.py | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/invenio_app_rdm/upgrade_scripts/migrate_13_0_to_14_0.py b/invenio_app_rdm/upgrade_scripts/migrate_13_0_to_14_0.py index 4027efa82..db35abfb6 100644 --- a/invenio_app_rdm/upgrade_scripts/migrate_13_0_to_14_0.py +++ b/invenio_app_rdm/upgrade_scripts/migrate_13_0_to_14_0.py @@ -19,6 +19,7 @@ 5. Update requests to make it ready for the commenting feature """ +import argparse import time from datetime import datetime, timezone @@ -388,7 +389,7 @@ def get_pending_count(): secho(f"⚠ Warning: {final_pending} documents still pending", fg="yellow") -def execute_upgrade(): +def execute_upgrade(migrate_theses=False): """Execute the upgrade from InvenioRDM 13.0 to 14.0. Please read the disclaimer on this module before thinking about executing @@ -402,13 +403,27 @@ def execute_upgrade(): records/drafts explicitly. this should improve speed and should make it easier to upgrade large instances + Args: + migrate_theses (bool): If True, run the migration for publication-thesis resource types. + Defaults to False. """ secho("Starting data migration...", fg="green") - run_update_for_resource_type() + if migrate_theses: + run_update_for_resource_type() run_update_for_request() # if the script is executed on its own, perform the upgrade if __name__ == "__main__": - execute_upgrade() + parser = argparse.ArgumentParser( + description="Execute the upgrade from InvenioRDM 13.0 to 14.0" + ) + parser.add_argument( + "--migrate-theses", + action="store_true", + default=False, + help="Run the migration for publication-thesis resource types." + ) + args = parser.parse_args() + execute_upgrade(migrate_theses=args.migrate_theses) diff --git a/tests/test_migrate_13_0_to_14_0.py b/tests/test_migrate_13_0_to_14_0.py index 87541e13b..60261172a 100644 --- a/tests/test_migrate_13_0_to_14_0.py +++ b/tests/test_migrate_13_0_to_14_0.py @@ -284,7 +284,7 @@ def test_migration( RDMRecord.index.refresh() # Run the complete migration - execute_upgrade() + execute_upgrade(migrate_theses=True) # Refresh indices before searching and testing RDMDraft.index.refresh()