-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
c528c69
commit 08bd09e
Showing
13 changed files
with
179 additions
and
5 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
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
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,46 @@ | ||
"""Add user status | ||
Revision ID: 99379162619e | ||
Revises: bc48af5ec2e6 | ||
Create Date: 2022-09-11 17:20:02.341713 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy import orm | ||
|
||
from ambuda.enums import UserStatus | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "99379162619e" | ||
down_revision = "bc48af5ec2e6" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
Base = orm.declarative_base() | ||
|
||
|
||
class User(Base): | ||
__tablename__ = "users" | ||
id = sa.Column(sa.Integer, primary_key=True) | ||
status = sa.Column(sa.String, default=UserStatus.ACTIVE.value, nullable=False) | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column("users", sa.Column("status", sa.String, nullable=True)) | ||
|
||
bind = op.get_bind() | ||
session = orm.Session(bind=bind) | ||
for user in session.query(User).all(): | ||
user.status = UserStatus.ACTIVE.value | ||
session.add(user) | ||
session.commit() | ||
|
||
with op.batch_alter_table("users") as batch_op: | ||
batch_op.alter_column("status", existing_type=sa.VARCHAR(), nullable=False) | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("users", "status") | ||
# ### 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
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