-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use uuid type for the new modules (#444)
- Loading branch information
1 parent
79b2b86
commit f42bab6
Showing
7 changed files
with
78 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
from datetime import date | ||
|
||
from sqlalchemy import Date, String | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
from sqlalchemy.orm import Mapped | ||
|
||
from app.types.sqlalchemy import Base | ||
from app.types.sqlalchemy import Base, PrimaryKey | ||
|
||
|
||
class Paper(Base): | ||
__tablename__ = "ph_papers" | ||
|
||
id: Mapped[str] = mapped_column(String, primary_key=True, index=True) | ||
name: Mapped[str] = mapped_column(String, nullable=False) | ||
release_date: Mapped[date] = mapped_column(Date, nullable=False) | ||
id: Mapped[PrimaryKey] | ||
name: Mapped[str] | ||
release_date: Mapped[date] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""fix uuid type | ||
Create Date: 2024-05-22 23:18:24.002804 | ||
""" | ||
|
||
from collections.abc import Sequence | ||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from pytest_alembic import MigrationContext | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "7b078dd0e7e4" | ||
down_revision: str | None = "fce1716123e2" | ||
branch_labels: str | Sequence[str] | None = None | ||
depends_on: str | Sequence[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
with op.batch_alter_table("ph_papers") as batch_op: | ||
batch_op.alter_column( | ||
"id", | ||
type_=sa.Uuid(), | ||
) | ||
op.drop_index("ix_ph_papers_id", table_name="ph_papers") | ||
|
||
|
||
def downgrade() -> None: | ||
op.create_index("ix_ph_papers_id", "ph_papers", ["id"], unique=False) | ||
with op.batch_alter_table("ph_papers") as batch_op: | ||
batch_op.alter_column( | ||
"id", | ||
type_=sa.String(), | ||
) | ||
|
||
|
||
def pre_test_upgrade( | ||
alembic_runner: "MigrationContext", | ||
alembic_connection: sa.Connection, | ||
) -> None: | ||
pass | ||
|
||
|
||
def test_upgrade( | ||
alembic_runner: "MigrationContext", | ||
alembic_connection: sa.Connection, | ||
) -> None: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters