-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unique constraint from username
With authlib we just need to have unique e-mail and we don't care about username anymore. This will prevent crash when the username exists in database but with different e-mail. Let this be handled by third party authentication systems. Signed-off-by: Michal Konecny <[email protected]>
- Loading branch information
Showing
3 changed files
with
28 additions
and
12 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
anitya/db/migrations/versions/ebc827e80373_remove_unique_attribute_from_username.py
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,25 @@ | ||
"""Remove unique attribute from username | ||
Revision ID: ebc827e80373 | ||
Revises: 8ba7d4c42044 | ||
Create Date: 2024-12-05 16:24:01.098473 | ||
""" | ||
|
||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'ebc827e80373' | ||
down_revision = '8ba7d4c42044' | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint('ix_users_username', 'users', type_='unique') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_unique_constraint('ix_users_username', 'users', ['username']) | ||
# ### 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1083,17 +1083,6 @@ def test_user_email_unique(self): | |
self.session.add(user) | ||
self.assertRaises(IntegrityError, self.session.commit) | ||
|
||
def test_username_unique(self): | ||
"""Assert User usernames have a uniqueness constraint on them.""" | ||
user = models.User(email="[email protected]", username="user") | ||
|
||
self.session.add(user) | ||
self.session.commit() | ||
|
||
user = models.User(email="[email protected]", username="user") | ||
self.session.add(user) | ||
self.assertRaises(IntegrityError, self.session.commit) | ||
|
||
def test_default_active(self): | ||
"""Assert User usernames have a uniqueness constraint on them.""" | ||
user = models.User(email="[email protected]", username="user") | ||
|