generated from MinBZK/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2142f62
commit 86e3c7e
Showing
6 changed files
with
90 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
"""a message | ||
Revision ID: eb2eed884ae9 | ||
Revises: | ||
Create Date: 2024-05-14 13:36:23.551663 | ||
""" | ||
|
||
from collections.abc import Sequence | ||
|
||
import sqlalchemy as sa | ||
import sqlmodel.sql.sqltypes | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "eb2eed884ae9" | ||
down_revision: str | None = None | ||
branch_labels: str | Sequence[str] | None = None | ||
depends_on: str | Sequence[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"hero", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"status", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False), | ||
sa.Column("sort_order", sa.Float(), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"user", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False), | ||
sa.Column("avatar", sqlmodel.sql.sqltypes.AutoString(), nullable=True), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_table( | ||
"task", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("title", sqlmodel.sql.sqltypes.AutoString(), nullable=False), | ||
sa.Column("description", sqlmodel.sql.sqltypes.AutoString(), nullable=False), | ||
sa.Column("sort_order", sa.Float(), nullable=False), | ||
sa.Column("status_id", sa.Integer(), nullable=False), | ||
sa.Column("user_id", sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint( | ||
["user_id"], | ||
["user.id"], | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table("task") | ||
op.drop_table("user") | ||
op.drop_table("status") | ||
op.drop_table("hero") | ||
# ### end Alembic commands ### |
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,3 +1,6 @@ | ||
from .hero import Hero | ||
from .status import Status | ||
from .task import Task | ||
from .user import User | ||
|
||
__all__ = ["Hero"] | ||
__all__ = ["Hero", "Task", "Status", "User"] |
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,7 +1,7 @@ | ||
from pydantic import BaseModel | ||
from sqlmodel import Field, SQLModel | ||
|
||
|
||
class Status(BaseModel): | ||
id: int | ||
class Status(SQLModel, table=True): | ||
id: int = Field(default=None, primary_key=True) | ||
name: str | ||
sort_order: float |
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,10 +1,10 @@ | ||
from pydantic import BaseModel | ||
from sqlmodel import Field, SQLModel | ||
|
||
|
||
class Task(BaseModel): | ||
id: int | ||
class Task(SQLModel, table=True): | ||
id: int = Field(default=None, primary_key=True) | ||
title: str | ||
description: str | ||
sort_order: float | ||
status_id: int | ||
user_id: int | None = None | ||
user_id: int | None = Field(default=None, foreign_key="user.id") |
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,6 +1,7 @@ | ||
from pydantic import BaseModel | ||
from sqlmodel import Field, SQLModel | ||
|
||
|
||
class User(BaseModel): | ||
id: int | ||
class User(SQLModel, table=True): | ||
id: int = Field(default=None, primary_key=True) | ||
name: str | ||
avatar: str | None |
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