make username not unique

This commit is contained in:
InigoAllende
2026-08-05 12:55:02 +02:00
parent f5dded5ae7
commit aaeb31521d
2 changed files with 33 additions and 1 deletions

View File

@@ -34,7 +34,7 @@ class User(DB.Model):
id: Mapped[str] = mapped_column(String(KEYCLOAK_ID_SIZE), primary_key=True, autoincrement=False)
email: Mapped[str] = mapped_column(String(128), unique=True, nullable=False)
username: Mapped[str] = mapped_column(String(150), unique=True, nullable=True)
username: Mapped[str] = mapped_column(String(150), unique=False, nullable=True)
is_staff: Mapped[bool] = mapped_column(Boolean, default=False)
is_active: Mapped[bool] = mapped_column(Boolean, default=True)

View File

@@ -0,0 +1,32 @@
"""empty message
Revision ID: 7c6cc24c9d34
Revises: 727eb738db92
Create Date: 2026-08-05 12:54:04.147726
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7c6cc24c9d34'
down_revision = '727eb738db92'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.drop_constraint(batch_op.f('uq_users_username'), type_='unique')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.create_unique_constraint(batch_op.f('uq_users_username'), ['username'])
# ### end Alembic commands ###