diff --git a/src/aiida/cmdline/commands/cmd_storage.py b/src/aiida/cmdline/commands/cmd_storage.py index 5382ff455f..c4fd17601a 100644 --- a/src/aiida/cmdline/commands/cmd_storage.py +++ b/src/aiida/cmdline/commands/cmd_storage.py @@ -41,12 +41,14 @@ def storage_migrate(force): from aiida.engine.daemon.client import get_daemon_client from aiida.manage import get_manager - client = get_daemon_client() - if client.is_daemon_running: - echo.echo_critical('Migration aborted, the daemon for the profile is still running.') - manager = get_manager() profile = manager.get_profile() + + if profile.process_control_backend: + client = get_daemon_client() + if client.is_daemon_running: + echo.echo_critical('Migration aborted, the daemon for the profile is still running.') + storage_cls = profile.storage_cls if not force: diff --git a/tests/cmdline/commands/test_storage.py b/tests/cmdline/commands/test_storage.py index 8c374885a2..eb629d013f 100644 --- a/tests/cmdline/commands/test_storage.py +++ b/tests/cmdline/commands/test_storage.py @@ -35,6 +35,15 @@ def tests_storage_info(aiida_localhost, run_cli_command): assert node.node_type in result.output +@pytest.mark.usefixtures('stopped_daemon_client') +def tests_storage_migrate_no_broker(aiida_config_tmp, aiida_profile_factory, run_cli_command): + """Test the ``verdi storage migrate`` command for a profile without a broker.""" + with aiida_profile_factory(aiida_config_tmp) as profile: + assert profile.process_control_backend is None + result = run_cli_command(cmd_storage.storage_migrate, parameters=['--force'], use_subprocess=False) + assert 'Migrating to the head of the main branch' in result.output + + @pytest.mark.usefixtures('stopped_daemon_client') def tests_storage_migrate_force(run_cli_command): """Test the ``verdi storage migrate`` command (with force option)."""