Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Rename link tables

Revision ID: b8a68f4260a4
Revises: 783268bd3daa
Create Date: 2025-11-18 19:07:48.518828

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

Check warning on line 11 in alembic/versions/2025_11_18_1907-b8a68f4260a4_rename_link_tables.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] alembic/versions/2025_11_18_1907-b8a68f4260a4_rename_link_tables.py#L11 <401>

'sqlalchemy as sa' imported but unused
Raw output
./alembic/versions/2025_11_18_1907-b8a68f4260a4_rename_link_tables.py:11:1: F401 'sqlalchemy as sa' imported but unused


# revision identifiers, used by Alembic.
revision: str = 'b8a68f4260a4'
down_revision: Union[str, None] = '783268bd3daa'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:

Check warning on line 21 in alembic/versions/2025_11_18_1907-b8a68f4260a4_rename_link_tables.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] alembic/versions/2025_11_18_1907-b8a68f4260a4_rename_link_tables.py#L21 <103>

Missing docstring in public function
Raw output
./alembic/versions/2025_11_18_1907-b8a68f4260a4_rename_link_tables.py:21:1: D103 Missing docstring in public function
old_name_new_name = {
"link_task_urls": "link_tasks__urls",
"link_agencies_locations": "link_agencies__locations",
"link_agency_batches": "link_agencies__batches",
"link_batch_urls": "link_batches__urls",
"link_location_batches": "link_batches__locations",
"link_urls_agency": "link_agencies__urls",
}
for old_name, new_name in old_name_new_name.items():
op.rename_table(old_name, new_name)


def downgrade() -> None:

Check warning on line 34 in alembic/versions/2025_11_18_1907-b8a68f4260a4_rename_link_tables.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] alembic/versions/2025_11_18_1907-b8a68f4260a4_rename_link_tables.py#L34 <103>

Missing docstring in public function
Raw output
./alembic/versions/2025_11_18_1907-b8a68f4260a4_rename_link_tables.py:34:1: D103 Missing docstring in public function
pass
2 changes: 1 addition & 1 deletion src/db/models/impl/agency/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ class Agency(
"LocationExpandedView",
primaryjoin="Agency.id == LinkAgencyLocation.agency_id",
secondaryjoin="LocationExpandedView.id == LinkAgencyLocation.location_id",
secondary="link_agencies_locations",
secondary="link_agencies__locations",
)
2 changes: 1 addition & 1 deletion src/db/models/impl/batch/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Batch(WithIDBase):
# Relationships
urls = relationship(
"URL",
secondary="link_batch_urls",
secondary="link_batches__urls",
back_populates="batch",
overlaps="url"
)
Expand Down
2 changes: 1 addition & 1 deletion src/db/models/impl/link/agency_batch/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LinkAgencyBatch(
BatchDependentMixin,
AgencyDependentMixin,
):
__tablename__ = "link_agency_batches"
__tablename__ = "link_agencies__batches"
__table_args__ = (
PrimaryKeyConstraint(
'batch_id',
Expand Down
2 changes: 1 addition & 1 deletion src/db/models/impl/link/agency_location/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
AgencyDependentMixin,
LocationDependentMixin,
):
__tablename__ = "link_agencies_locations"
__tablename__ = "link_agencies__locations"

Check warning on line 10 in src/db/models/impl/link/agency_location/sqlalchemy.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] src/db/models/impl/link/agency_location/sqlalchemy.py#L10 <292>

no newline at end of file
Raw output
./src/db/models/impl/link/agency_location/sqlalchemy.py:10:47: W292 no newline at end of file
2 changes: 1 addition & 1 deletion src/db/models/impl/link/batch_url/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class LinkBatchURL(
BatchDependentMixin,
WithIDBase
):
__tablename__ = "link_batch_urls"
__tablename__ = "link_batches__urls"

2 changes: 1 addition & 1 deletion src/db/models/impl/link/location_batch/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LinkLocationBatch(
CreatedAtMixin
):

__tablename__ = "link_location_batches"
__tablename__ = "link_batches__locations"
__table_args__ = (
PrimaryKeyConstraint(
'batch_id',
Expand Down
2 changes: 1 addition & 1 deletion src/db/models/impl/link/task_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class LinkTaskURL(Base):
__tablename__ = 'link_task_urls'
__tablename__ = 'link_tasks__urls'
__table_args__ = (UniqueConstraint(
"task_id",
"url_id",
Expand Down
2 changes: 1 addition & 1 deletion src/db/models/impl/link/url_agency/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class LinkURLAgency(URLDependentMixin, WithIDBase):
__tablename__ = "link_urls_agency"
__tablename__ = "link_agencies__urls"

agency_id: Mapped[int] = get_agency_id_foreign_column()

Expand Down
2 changes: 1 addition & 1 deletion src/db/models/impl/task/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Task(UpdatedAtMixin, WithIDBase):
# Relationships
urls = relationship(
"URL",
secondary="link_task_urls",
secondary="link_tasks__urls",
back_populates="tasks"
)
errors = relationship(TaskError)
Expand Down
6 changes: 3 additions & 3 deletions src/db/models/impl/url/core/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def full_url(cls):
# Relationships
batch = relationship(
"Batch",
secondary="link_batch_urls",
secondary="link_batches__urls",
back_populates="urls",
uselist=False,
)
Expand All @@ -82,7 +82,7 @@ def full_url(cls):
)
tasks = relationship(
"Task",
secondary="link_task_urls",
secondary="link_tasks__urls",
back_populates="urls",
)
auto_agency_subtasks = relationship(
Expand Down Expand Up @@ -110,7 +110,7 @@ def full_url(cls):
"URLOptionalDataSourceMetadata", uselist=False, back_populates="url")
confirmed_agencies = relationship(
"Agency",
secondary="link_urls_agency"
secondary="link_agencies__urls"

)
data_source = relationship(
Expand Down
6 changes: 3 additions & 3 deletions src/db/models/views/batch_url_status/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
select
1
from
link_batch_urls lbu
link_batches__urls lbu
where
lbu.batch_id = b.id
)
Expand All @@ -26,7 +26,7 @@
select
1
from
link_batch_urls lbu
link_batches__urls lbu
left join flag_url_validated fuv on fuv.url_id = lbu.url_id
where
lbu.batch_id = b.id
Expand All @@ -36,7 +36,7 @@
select
1
from
link_batch_urls lbu
link_batches__urls lbu
left join flag_url_validated fuv on fuv.url_id = lbu.url_id
where
lbu.batch_id = b.id
Expand Down
2 changes: 1 addition & 1 deletion src/db/models/views/url_annotations_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
LEFT JOIN public.user_relevant_suggestions urs ON u.id = urs.url_id
LEFT JOIN public.user_url_agency_suggestions uuas ON u.id = uuas.url_id
LEFT JOIN public.reviewing_user_url ruu ON u.id = ruu.url_id
LEFT JOIN public.link_urls_agency cua on u.id = cua.url_id
LEFT JOIN public.link_agencies__urls cua on u.id = cua.url_id
)
"""

Expand Down