Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING] - remove is_deleted for Connection model #170

Merged
merged 2 commits into from
Dec 16, 2024
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
1 change: 1 addition & 0 deletions docs/changelog/next_release/170.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add deletion of **connections** records instead of marking them as deleted
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def upgrade():
sa.Column("name", sa.String(length=128), nullable=False),
sa.Column("description", sa.String(length=512), nullable=False),
sa.Column("data", sa.JSON(), nullable=False),
sa.Column("is_deleted", sa.Boolean(), nullable=False),
sa.Column("created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False),
sa.Column("updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False),
sa.Column("search_vector", postgresql.TSVECTOR(), sa.Computed(sql_expression, persisted=True), nullable=False),
Expand Down
4 changes: 2 additions & 2 deletions syncmaster/db/models/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from sqlalchemy.dialects.postgresql import TSVECTOR
from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship

from syncmaster.db.mixins import DeletableMixin, ResourceMixin, TimestampMixin
from syncmaster.db.mixins import ResourceMixin, TimestampMixin
from syncmaster.db.models.base import Base
from syncmaster.db.models.group import Group


class Connection(Base, ResourceMixin, DeletableMixin, TimestampMixin):
class Connection(Base, ResourceMixin, TimestampMixin):
data: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False, default={})

group: Mapped[Group] = relationship("Group")
Expand Down
4 changes: 1 addition & 3 deletions syncmaster/db/repositories/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ async def paginate(
connection_type: list[str] | None = None,
) -> Pagination:
stmt = select(Connection).where(
Connection.is_deleted.is_(False),
Connection.group_id == group_id,
)
if search_query:
Expand All @@ -53,7 +52,7 @@ async def read_by_id(
self,
connection_id: int,
) -> Connection:
stmt = select(Connection).where(Connection.id == connection_id, Connection.is_deleted.is_(False))
stmt = select(Connection).where(Connection.id == connection_id)
result: ScalarResult[Connection] = await self._session.scalars(stmt)
try:
return result.one()
Expand Down Expand Up @@ -99,7 +98,6 @@ async def update(

return await self._update(
Connection.id == connection_id,
Connection.is_deleted.is_(False),
name=name or connection.name,
description=description or connection.description,
data=data,
Expand Down
Loading
Loading