Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from bugout-dev/web3-user-auth
Web3 user authentification
- Loading branch information
Showing
11 changed files
with
763 additions
and
240 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
"""Web3 users | ||
Revision ID: 6bc0ee79a3ce | ||
Revises: 6ae8af4e1863 | ||
Create Date: 2022-09-14 10:41:57.439633 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '6bc0ee79a3ce' | ||
down_revision = '6ae8af4e1863' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column('users', sa.Column('web3_address', sa.String(), nullable=True)) | ||
op.alter_column('users', 'email', | ||
existing_type=sa.VARCHAR(), | ||
nullable=True) | ||
op.alter_column('users', 'normalized_email', | ||
existing_type=sa.VARCHAR(), | ||
nullable=True) | ||
op.alter_column('users', 'password_hash', | ||
existing_type=sa.VARCHAR(), | ||
nullable=True) | ||
op.drop_index('uq_users_normalized_email_no_application_id', table_name='users') | ||
op.drop_index('uq_users_username_no_application_id', table_name='users') | ||
op.create_index(op.f('ix_users_web3_address'), 'users', ['web3_address'], unique=False) | ||
op.create_index('uq_users_normalized_email', 'users', ['normalized_email'], unique=True, postgresql_where=sa.text('application_id IS NULL')) | ||
op.create_index('uq_users_username', 'users', ['username'], unique=True, postgresql_where=sa.text('application_id IS NULL')) | ||
op.create_index('uq_users_web3_address', 'users', ['web3_address'], unique=True, postgresql_where=sa.text('application_id IS NULL')) | ||
op.create_index('uq_users_web3_address_application_id', 'users', ['web3_address', 'application_id'], unique=True, postgresql_where=sa.text('application_id IS NOT NULL')) | ||
op.drop_column('users', 'auth_type') | ||
|
||
op.execute("ALTER TABLE users ADD CONSTRAINT ck_users_normalized_email_password_hash CHECK ((normalized_email IS NULL) OR (normalized_email IS NOT NULL AND password_hash IS NOT NULL));") | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column('users', sa.Column('auth_type', sa.VARCHAR(length=50), autoincrement=False, nullable=False)) | ||
op.drop_index('uq_users_web3_address_application_id', table_name='users', postgresql_where=sa.text('application_id IS NOT NULL')) | ||
op.drop_index('uq_users_web3_address', table_name='users', postgresql_where=sa.text('application_id IS NULL')) | ||
op.drop_index('uq_users_username', table_name='users', postgresql_where=sa.text('application_id IS NULL')) | ||
op.drop_index('uq_users_normalized_email', table_name='users', postgresql_where=sa.text('application_id IS NULL')) | ||
op.drop_index(op.f('ix_users_web3_address'), table_name='users') | ||
op.create_index('uq_users_username_no_application_id', 'users', ['username'], unique=False) | ||
op.create_index('uq_users_normalized_email_no_application_id', 'users', ['normalized_email'], unique=False) | ||
op.alter_column('users', 'password_hash', | ||
existing_type=sa.VARCHAR(), | ||
nullable=False) | ||
op.alter_column('users', 'normalized_email', | ||
existing_type=sa.VARCHAR(), | ||
nullable=False) | ||
op.alter_column('users', 'email', | ||
existing_type=sa.VARCHAR(), | ||
nullable=False) | ||
op.drop_column('users', 'web3_address') | ||
|
||
op.drop_constraint("ck_users_normalized_email_password_hash", table_name="users") | ||
# ### end Alembic commands ### |
Oops, something went wrong.