diff --git a/aiida/storage/psql_dos/migrations/utils/integrity.py b/aiida/storage/psql_dos/migrations/utils/integrity.py index f51f48163e..6f3e14e2bf 100644 --- a/aiida/storage/psql_dos/migrations/utils/integrity.py +++ b/aiida/storage/psql_dos/migrations/utils/integrity.py @@ -186,14 +186,12 @@ def write_database_integrity_violation(results, headers, reason_message, action_ handle.write(tabulate(results, headers)) -# Currently valid hash key -_HASH_EXTRA_KEY = '_aiida_hash' - - -def drop_hashes(conn): +def drop_hashes(conn, hash_extra_key): """Drop hashes of nodes. Print warning only if the DB actually contains nodes. + + :param hash_extra_key: The key in the extras used to store the hash at the time of this migration. """ # Remove when https://github.com/PyCQA/pylint/issues/1931 is fixed # pylint: disable=no-name-in-module,import-error @@ -204,5 +202,5 @@ def drop_hashes(conn): if n_nodes > 0: echo.echo_warning('Invalidating the hashes of all nodes. Please run "verdi rehash".', bold=True) - statement = text(f"UPDATE db_dbnode SET extras = extras #- '{{{_HASH_EXTRA_KEY}}}'::text[];") + statement = text(f"UPDATE db_dbnode SET extras = extras #- '{{{hash_extra_key}}}'::text[];") conn.execute(statement) diff --git a/aiida/storage/psql_dos/migrations/versions/django_0039_reset_hash.py b/aiida/storage/psql_dos/migrations/versions/django_0039_reset_hash.py index eb0bd3b14c..32e4afeb27 100644 --- a/aiida/storage/psql_dos/migrations/versions/django_0039_reset_hash.py +++ b/aiida/storage/psql_dos/migrations/versions/django_0039_reset_hash.py @@ -28,9 +28,9 @@ def upgrade(): """Migrations for the upgrade.""" - drop_hashes(op.get_bind()) # pylint: disable=no-member + drop_hashes(op.get_bind(), hash_extra_key='_aiida_hash') # pylint: disable=no-member def downgrade(): """Migrations for the downgrade.""" - drop_hashes(op.get_bind()) # pylint: disable=no-member + drop_hashes(op.get_bind(), hash_extra_key='_aiida_hash') # pylint: disable=no-member diff --git a/aiida/storage/psql_dos/migrations/versions/e797afa09270_reset_hash.py b/aiida/storage/psql_dos/migrations/versions/e797afa09270_reset_hash.py index cc77888fdf..2459138677 100644 --- a/aiida/storage/psql_dos/migrations/versions/e797afa09270_reset_hash.py +++ b/aiida/storage/psql_dos/migrations/versions/e797afa09270_reset_hash.py @@ -30,9 +30,9 @@ def upgrade(): """drop the hashes when upgrading""" - drop_hashes(op.get_bind()) # pylint: disable=no-member + drop_hashes(op.get_bind(), hash_extra_key='_aiida_hash') # pylint: disable=no-member def downgrade(): """drop the hashes also when downgrading""" - drop_hashes(op.get_bind()) # pylint: disable=no-member + drop_hashes(op.get_bind(), hash_extra_key='_aiida_hash') # pylint: disable=no-member