Skip to content

Commit 3e728ab

Browse files
authored
Merge pull request #525 from Police-Data-Accessibility-Project/mc_512_rename_link_tables
Rename link tables
2 parents 8920518 + bdcd211 commit 3e728ab

File tree

13 files changed

+51
-16
lines changed

13 files changed

+51
-16
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Rename link tables
2+
3+
Revision ID: b8a68f4260a4
4+
Revises: 783268bd3daa
5+
Create Date: 2025-11-18 19:07:48.518828
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = 'b8a68f4260a4'
16+
down_revision: Union[str, None] = '783268bd3daa'
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
old_name_new_name = {
23+
"link_task_urls": "link_tasks__urls",
24+
"link_agencies_locations": "link_agencies__locations",
25+
"link_agency_batches": "link_agencies__batches",
26+
"link_batch_urls": "link_batches__urls",
27+
"link_location_batches": "link_batches__locations",
28+
"link_urls_agency": "link_agencies__urls",
29+
}
30+
for old_name, new_name in old_name_new_name.items():
31+
op.rename_table(old_name, new_name)
32+
33+
34+
def downgrade() -> None:
35+
pass

src/db/models/impl/agency/sqlalchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ class Agency(
3535
"LocationExpandedView",
3636
primaryjoin="Agency.id == LinkAgencyLocation.agency_id",
3737
secondaryjoin="LocationExpandedView.id == LinkAgencyLocation.location_id",
38-
secondary="link_agencies_locations",
38+
secondary="link_agencies__locations",
3939
)

src/db/models/impl/batch/sqlalchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Batch(WithIDBase):
4141
# Relationships
4242
urls = relationship(
4343
"URL",
44-
secondary="link_batch_urls",
44+
secondary="link_batches__urls",
4545
back_populates="batch",
4646
overlaps="url"
4747
)

src/db/models/impl/link/agency_batch/sqlalchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class LinkAgencyBatch(
1010
BatchDependentMixin,
1111
AgencyDependentMixin,
1212
):
13-
__tablename__ = "link_agency_batches"
13+
__tablename__ = "link_agencies__batches"
1414
__table_args__ = (
1515
PrimaryKeyConstraint(
1616
'batch_id',

src/db/models/impl/link/agency_location/sqlalchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ class LinkAgencyLocation(
77
AgencyDependentMixin,
88
LocationDependentMixin,
99
):
10-
__tablename__ = "link_agencies_locations"
10+
__tablename__ = "link_agencies__locations"

src/db/models/impl/link/batch_url/sqlalchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ class LinkBatchURL(
1111
BatchDependentMixin,
1212
WithIDBase
1313
):
14-
__tablename__ = "link_batch_urls"
14+
__tablename__ = "link_batches__urls"
1515

src/db/models/impl/link/location_batch/sqlalchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class LinkLocationBatch(
1111
CreatedAtMixin
1212
):
1313

14-
__tablename__ = "link_location_batches"
14+
__tablename__ = "link_batches__locations"
1515
__table_args__ = (
1616
PrimaryKeyConstraint(
1717
'batch_id',

src/db/models/impl/link/task_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class LinkTaskURL(Base):
7-
__tablename__ = 'link_task_urls'
7+
__tablename__ = 'link_tasks__urls'
88
__table_args__ = (UniqueConstraint(
99
"task_id",
1010
"url_id",

src/db/models/impl/link/url_agency/sqlalchemy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class LinkURLAgency(URLDependentMixin, WithIDBase):
10-
__tablename__ = "link_urls_agency"
10+
__tablename__ = "link_agencies__urls"
1111

1212
agency_id: Mapped[int] = get_agency_id_foreign_column()
1313

src/db/models/impl/task/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Task(UpdatedAtMixin, WithIDBase):
3232
# Relationships
3333
urls = relationship(
3434
"URL",
35-
secondary="link_task_urls",
35+
secondary="link_tasks__urls",
3636
back_populates="tasks"
3737
)
3838
errors = relationship(TaskError)

0 commit comments

Comments
 (0)