From 34295b234fa208eb673aa2904551bc1fec8881cc Mon Sep 17 00:00:00 2001 From: Niraj Adhikari Date: Wed, 10 Jul 2024 11:14:04 +0545 Subject: [PATCH] username field removed from users table --- src/backend/app/db/db_models.py | 5 ++- .../app/migrations/versions/88ae62ec8876_.py | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/backend/app/migrations/versions/88ae62ec8876_.py diff --git a/src/backend/app/db/db_models.py b/src/backend/app/db/db_models.py index a2cf8fad..d2929a0d 100644 --- a/src/backend/app/db/db_models.py +++ b/src/backend/app/db/db_models.py @@ -37,13 +37,12 @@ class DbUser(Base): __tablename__ = "users" id = cast(str, Column(String, primary_key=True)) - username = cast(str, Column(String, nullable=False, unique=True)) + email_address = cast(str, Column(String, nullable=False, unique=True)) password = cast(str, Column(String)) + name = cast(str, Column(String)) is_active = cast(bool, Column(Boolean, default=False)) is_superuser = cast(bool, Column(Boolean, default=False)) profile_img = cast(str, Column(String, nullable=True)) - name = cast(str, Column(String)) - email_address = cast(str, Column(String, nullable=False, unique=True)) date_registered = cast(datetime, Column(DateTime, default=timestamp)) diff --git a/src/backend/app/migrations/versions/88ae62ec8876_.py b/src/backend/app/migrations/versions/88ae62ec8876_.py new file mode 100644 index 00000000..94758111 --- /dev/null +++ b/src/backend/app/migrations/versions/88ae62ec8876_.py @@ -0,0 +1,35 @@ +""" + +Revision ID: 88ae62ec8876 +Revises: 3293e9c98b2a +Create Date: 2024-07-10 05:21:58.749137 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = "88ae62ec8876" +down_revision: Union[str, None] = "3293e9c98b2a" +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.drop_constraint("users_username_key", "users", type_="unique") + op.drop_column("users", "username") + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column( + "users", + sa.Column("username", sa.VARCHAR(), autoincrement=False, nullable=False), + ) + op.create_unique_constraint("users_username_key", "users", ["username"]) + # ### end Alembic commands ###