Skip to content

Commit

Permalink
added is_active field to users table
Browse files Browse the repository at this point in the history
  • Loading branch information
Armolas committed Jul 20, 2024
1 parent 31c86af commit 3a6a1ef
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
30 changes: 30 additions & 0 deletions alembic/versions/6a60cb2e3102_added_is_active_field_to_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""added is_active field to users
Revision ID: 6a60cb2e3102
Revises: 17be96741cf5
Create Date: 2024-07-20 01:06:54.780108
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '6a60cb2e3102'
down_revision: Union[str, None] = '17be96741cf5'
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('users', sa.Column('is_active', sa.Boolean(), nullable=True))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'is_active')
# ### end Alembic commands ###
4 changes: 3 additions & 1 deletion api/v1/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
Numeric,
DateTime,
func,
Table
Table,
Boolean
)
from sqlalchemy.orm import relationship
from datetime import datetime
Expand All @@ -31,6 +32,7 @@ class User(BaseModel, Base):
password = Column(String(255), nullable=False)
first_name = Column(String(50))
last_name = Column(String(50))
is_active = Column(Boolean, default=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())

Expand Down

0 comments on commit 3a6a1ef

Please sign in to comment.