diff --git a/app/models/user.py b/app/models/user.py index 68e9fdd..a26a8fa 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -12,8 +12,8 @@ class User(db.Model): first_name: Mapped[str] = mapped_column(nullable=True) last_name: Mapped[str] = mapped_column(nullable=True) - phone: Mapped[str] = mapped_column(nullable=True, unique=True) - username: Mapped[str] = mapped_column(nullable=True, unique=True) + phone: Mapped[str] = mapped_column(nullable=True) + username: Mapped[str] = mapped_column(nullable=True) collection_id = Column(Integer, ForeignKey("collection.id")) collection: Mapped["Collection"] = relationship("Collection", back_populates="users") diff --git a/migrations/versions/11ed77b4dbe8_phone_and_username_not_unique.py b/migrations/versions/11ed77b4dbe8_phone_and_username_not_unique.py new file mode 100644 index 0000000..7a7bf70 --- /dev/null +++ b/migrations/versions/11ed77b4dbe8_phone_and_username_not_unique.py @@ -0,0 +1,34 @@ +"""phone and username not unique + +Revision ID: 11ed77b4dbe8 +Revises: d573f6529ad5 +Create Date: 2024-03-09 22:59:14.088171 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '11ed77b4dbe8' +down_revision = 'd573f6529ad5' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.drop_constraint('user_phone_key', type_='unique') + batch_op.drop_constraint('user_username_key', type_='unique') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.create_unique_constraint('user_username_key', ['username']) + batch_op.create_unique_constraint('user_phone_key', ['phone']) + + # ### end Alembic commands ###