mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-18 20:09:25 +00:00
feat: add details and profile fields to User model with JSON support
This commit is contained in:
parent
af17deff30
commit
6ff53915a8
2 changed files with 38 additions and 1 deletions
|
|
@ -0,0 +1,33 @@
|
|||
"""Add Users details and Profile
|
||||
|
||||
Revision ID: adb944cc8bec
|
||||
Revises: 4a88b680263c
|
||||
Create Date: 2025-03-29 16:31:38.797525
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa # noqa: F401
|
||||
import sqlmodel # noqa: F401
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'adb944cc8bec'
|
||||
down_revision: Union[str, None] = '4a88b680263c'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('user', sa.Column('details', sa.JSON(), nullable=True))
|
||||
op.add_column('user', sa.Column('profile', sa.JSON(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('user', 'profile')
|
||||
op.drop_column('user', 'details')
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Optional
|
||||
from pydantic import BaseModel, EmailStr
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlalchemy import JSON, Column
|
||||
from src.db.roles import RoleRead
|
||||
|
||||
|
||||
|
|
@ -12,7 +13,8 @@ class UserBase(SQLModel):
|
|||
email: EmailStr
|
||||
avatar_image: Optional[str] = ""
|
||||
bio: Optional[str] = ""
|
||||
|
||||
details: Optional[dict] = Field(default={}, sa_column=Column(JSON))
|
||||
profile: Optional[dict] = Field(default={}, sa_column=Column(JSON))
|
||||
|
||||
class UserCreate(UserBase):
|
||||
first_name: str = ""
|
||||
|
|
@ -27,6 +29,8 @@ class UserUpdate(UserBase):
|
|||
email: str
|
||||
avatar_image: Optional[str] = ""
|
||||
bio: Optional[str] = ""
|
||||
details: Optional[dict] = {}
|
||||
profile: Optional[dict] = {}
|
||||
|
||||
|
||||
class UserUpdatePassword(SQLModel):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue