From 7aad2976ddc46bc5720d90dcd2afb6da484d95a9 Mon Sep 17 00:00:00 2001 From: Radu Carpa Date: Wed, 27 Sep 2023 10:56:32 +0200 Subject: [PATCH] Core & Internals: drop support for old distances DB format. Closes #6367 The code was intended to allow both 1.29 and 1.30 servers to run in parallel on the same database. This should have no effect on everybody who correctly applied the migrations. --- lib/rucio/db/sqla/models.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/rucio/db/sqla/models.py b/lib/rucio/db/sqla/models.py index 298df358d6..e6337ba0e8 100644 --- a/lib/rucio/db/sqla/models.py +++ b/lib/rucio/db/sqla/models.py @@ -17,7 +17,7 @@ from datetime import datetime, timedelta from typing import Any, Optional, Union -from sqlalchemy import BigInteger, Boolean, DateTime, Enum, Float, Integer, SmallInteger, String, Text, event, UniqueConstraint, inspect +from sqlalchemy import BigInteger, Boolean, DateTime, Enum, Float, Integer, SmallInteger, String, Text, event, UniqueConstraint from sqlalchemy.engine import Engine from sqlalchemy.ext.compiler import compiles from sqlalchemy.ext.declarative import declared_attr @@ -34,7 +34,7 @@ RuleState, ReplicaState, RequestState, RequestType, RSEType, ScopeStatus, SubscriptionState, RuleNotification, LifetimeExceptionsState, BadPFNStatus, TransferLimitDirection) -from rucio.db.sqla.session import BASE, get_engine +from rucio.db.sqla.session import BASE from rucio.db.sqla.types import GUID, BooleanString, JSON from rucio.db.sqla.types import InternalAccountString from rucio.db.sqla.types import InternalScopeString @@ -1408,24 +1408,12 @@ class SourceHistory(BASE, ModelBase): ) -# Compatibility code to permit 1.30 to run with a distances table from the 1.29 database schema -# TODO: remove this code in rucio 1.31 -_distance_column_name = 'distance' -_engine = get_engine() -if _engine.dialect.name in ['oracle', 'mysql', 'postgresql']: - _insp = inspect(_engine) - if _engine.dialect.name in ['oracle', 'postgresql'] or BASE.metadata.schema in _insp.get_schema_names(): - if 'distances' in _insp.get_table_names(schema=BASE.metadata.schema): - if any(c['name'] == 'ranking' for c in _insp.get_columns(table_name='distances', schema=BASE.metadata.schema)): - _distance_column_name = 'ranking' - - class Distance(BASE, ModelBase): """Represents distance between rses""" __tablename__ = 'distances' src_rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) dest_rse_id: Mapped[uuid.UUID] = mapped_column(GUID()) - distance: Mapped[Optional[int]] = mapped_column(Integer(), name=_distance_column_name) + distance: Mapped[Optional[int]] = mapped_column(Integer()) _table_args = (PrimaryKeyConstraint('src_rse_id', 'dest_rse_id', name='DISTANCES_PK'), ForeignKeyConstraint(['src_rse_id'], ['rses.id'], name='DISTANCES_SRC_RSES_FK'), ForeignKeyConstraint(['dest_rse_id'], ['rses.id'], name='DISTANCES_DEST_RSES_FK'),