GeezerVison is showing github.com — refactor: user infrastructure models use integer foreign keys · IDTS-LAB/python-codebase@d260fa8
File treeExpand file treeCollapse file tree Open diff view settings src/modules/user/infrastructure/models
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/modules/user/infrastructure/models/refresh_token_model.py +1-4Lines changed: 1 addition & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | from datetime import datetime | 2 | | -from uuid import UUID | 3 | 2 |
| 4 | 3 | from sqlalchemy import Boolean, DateTime, ForeignKey, Index, String | 5 | | -from sqlalchemy.dialects.postgresql import UUID as PG_UUID | 6 | 4 | from sqlalchemy.orm import Mapped, mapped_column, relationship | 7 | 5 |
| 8 | 6 | from src.shared.database.mixin.tenant import TenantMixin | @@ -26,8 +24,7 @@ class UserSessionModel(Base, TimeStampMixin, SoftDeleteMixin, TenantMixin): | 26 | 24 | Index("ix_user_sessions_device_info", "device_info"), | 27 | 25 | ) | 28 | 26 |
| 29 | | - user_id: Mapped[UUID] = mapped_column( | 30 | | - PG_UUID(as_uuid=True), | | 27 | + user_id: Mapped[int] = mapped_column( | 31 | 28 | ForeignKey("users.id"), | 32 | 29 | nullable=False, | 33 | 30 | ) | |
Collapse file Copy file name to clipboardExpand all lines: src/modules/user/infrastructure/models/user_address_model.py +1-5Lines changed: 1 addition & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -from uuid import UUID | 2 | | - | 3 | 1 | from sqlalchemy import Boolean, ForeignKey, Index, String | 4 | | -from sqlalchemy.dialects.postgresql import UUID as PG_UUID | 5 | 2 | from sqlalchemy.orm import Mapped, mapped_column, relationship | 6 | 3 |
| 7 | 4 | from src.modules.user.infrastructure.models.user_model import UserModel | @@ -25,8 +22,7 @@ class UserAddressModel(Base, TimeStampMixin, SoftDeleteMixin, TenantMixin): | 25 | 22 | Index("ix_user_addresses_country", "country"), | 26 | 23 | ) | 27 | 24 |
| 28 | | - user_id: Mapped[UUID] = mapped_column( | 29 | | - PG_UUID(as_uuid=True), | | 25 | + user_id: Mapped[int] = mapped_column( | 30 | 26 | ForeignKey("users.id"), | 31 | 27 | nullable=False, | 32 | 28 | ) | |
Collapse file Copy file name to clipboardExpand all lines: src/modules/user/infrastructure/models/user_contact_model.py +1-4Lines changed: 1 addition & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | from enum import Enum | 2 | | -from uuid import UUID | 3 | 2 |
| 4 | 3 | from sqlalchemy import Boolean, ForeignKey, Index, String | 5 | | -from sqlalchemy.dialects.postgresql import UUID as PG_UUID | 6 | 4 | from sqlalchemy.orm import Mapped, mapped_column, relationship | 7 | 5 |
| 8 | 6 | from src.modules.user.infrastructure.models.user_model import UserModel | @@ -34,8 +32,7 @@ class UserContactModel(Base, TimeStampMixin, SoftDeleteMixin, TenantMixin): | 34 | 32 | Index("ix_user_contacts_is_primary", "is_primary"), | 35 | 33 | ) | 36 | 34 |
| 37 | | - user_id: Mapped[UUID] = mapped_column( | 38 | | - PG_UUID(as_uuid=True), | | 35 | + user_id: Mapped[int] = mapped_column( | 39 | 36 | ForeignKey("users.id"), | 40 | 37 | nullable=False, | 41 | 38 | ) | |
Collapse file Copy file name to clipboardExpand all lines: src/modules/user/infrastructure/models/user_profile_model.py +1-5Lines changed: 1 addition & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -from uuid import UUID | 2 | | - | 3 | 1 | from sqlalchemy import Date, ForeignKey, Index, String, Text | 4 | | -from sqlalchemy.dialects.postgresql import UUID as PG_UUID | 5 | 2 | from sqlalchemy.orm import Mapped, mapped_column, relationship | 6 | 3 |
| 7 | 4 | from src.modules.user.infrastructure.models.user_model import UserModel | @@ -20,8 +17,7 @@ class UserProfileModel(Base, TimeStampMixin, SoftDeleteMixin, TenantMixin): | 20 | 17 | __tablename__ = "user_profiles" | 21 | 18 | __table_args__ = (Index("ix_user_profiles_user_id", "user_id", unique=True),) | 22 | 19 |
| 23 | | - user_id: Mapped[UUID] = mapped_column( | 24 | | - PG_UUID(as_uuid=True), | | 20 | + user_id: Mapped[int] = mapped_column( | 25 | 21 | ForeignKey("users.id"), | 26 | 22 | unique=True, | 27 | 23 | nullable=False, | |
Collapse file Copy file name to clipboardExpand all lines: src/modules/user/infrastructure/models/user_security_model.py +1-4Lines changed: 1 addition & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | from datetime import datetime | 2 | | -from uuid import UUID | 3 | 2 |
| 4 | 3 | from sqlalchemy import Boolean, DateTime, ForeignKey, Index, Integer, String | 5 | | -from sqlalchemy.dialects.postgresql import UUID as PG_UUID | 6 | 4 | from sqlalchemy.orm import Mapped, mapped_column, relationship | 7 | 5 |
| 8 | 6 | from src.modules.user.infrastructure.models.user_model import UserModel | @@ -25,8 +23,7 @@ class UserSecurityModel(Base, TimeStampMixin, SoftDeleteMixin, TenantMixin): | 25 | 23 | Index("ix_user_security_two_factor_enabled", "two_factor_enabled"), | 26 | 24 | ) | 27 | 25 |
| 28 | | - user_id: Mapped[UUID] = mapped_column( | 29 | | - PG_UUID(as_uuid=True), | | 26 | + user_id: Mapped[int] = mapped_column( | 30 | 27 | ForeignKey("users.id"), | 31 | 28 | unique=True, | 32 | 29 | nullable=False, | |
Collapse file Copy file name to clipboardExpand all lines: src/modules/user/infrastructure/models/user_settings_model.py +1-5Lines changed: 1 addition & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -from uuid import UUID | 2 | | - | 3 | 1 | from sqlalchemy import ForeignKey, Index | 4 | 2 | from sqlalchemy.dialects.postgresql import JSONB | 5 | | -from sqlalchemy.dialects.postgresql import UUID as PG_UUID | 6 | 3 | from sqlalchemy.orm import Mapped, mapped_column, relationship | 7 | 4 |
| 8 | 5 | from src.modules.user.infrastructure.models.user_model import UserModel | @@ -41,8 +38,7 @@ class UserSettingsModel(Base, TimeStampMixin, SoftDeleteMixin, TenantMixin): | 41 | 38 | Index("ix_user_settings_preferences", "preferences", postgresql_using="gin"), | 42 | 39 | ) | 43 | 40 |
| 44 | | - user_id: Mapped[UUID] = mapped_column( | 45 | | - PG_UUID(as_uuid=True), | | 41 | + user_id: Mapped[int] = mapped_column( | 46 | 42 | ForeignKey("users.id"), | 47 | 43 | unique=True, | 48 | 44 | nullable=False, | |
Collapse file Copy file name to clipboardExpand all lines: src/modules/user/infrastructure/models/user_verification_model.py +1-4Lines changed: 1 addition & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | from datetime import datetime | 2 | | -from uuid import UUID | 3 | 2 |
| 4 | 3 | from sqlalchemy import Boolean, DateTime, ForeignKey, Index, String | 5 | | -from sqlalchemy.dialects.postgresql import UUID as PG_UUID | 6 | 4 | from sqlalchemy.orm import Mapped, mapped_column, relationship | 7 | 5 |
| 8 | 6 | from src.modules.user.infrastructure.models.user_model import UserModel | @@ -26,8 +24,7 @@ class UserVerificationModel(Base, TimeStampMixin, SoftDeleteMixin, TenantMixin): | 26 | 24 | Index("ix_user_verifications_token", "verification_token"), | 27 | 25 | ) | 28 | 26 |
| 29 | | - user_id: Mapped[UUID] = mapped_column( | 30 | | - PG_UUID(as_uuid=True), | | 27 | + user_id: Mapped[int] = mapped_column( | 31 | 28 | ForeignKey("users.id"), | 32 | 29 | nullable=False, | 33 | 30 | ) | |
|