Skip to content

Commit

Permalink
Core & Internals: remove support for old distances table format
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Radu Carpa committed Nov 10, 2023
1 parent 4380d02 commit 78f45ed
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions lib/rucio/db/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(), name='distance')
_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'),
Expand Down

0 comments on commit 78f45ed

Please sign in to comment.