diff --git a/app/models.py b/app/models.py index 3e4fe7c4..65a3b8c4 100644 --- a/app/models.py +++ b/app/models.py @@ -236,6 +236,7 @@ class Fido(Base, ModelMixin): public_key = sa.Column(sa.String(), nullable=False, unique=True) sign_count = sa.Column(sa.BigInteger(), nullable=False) name = sa.Column(sa.String(128), nullable=False, unique=False) + user_id = sa.Column(sa.ForeignKey("users.id", ondelete="cascade"), nullable=True) class User(Base, ModelMixin, UserMixin, PasswordOracle): diff --git a/migrations/versions/2021_112212_d0ccd9d7ac0c_.py b/migrations/versions/2021_112212_d0ccd9d7ac0c_.py new file mode 100644 index 00000000..1c3e64e8 --- /dev/null +++ b/migrations/versions/2021_112212_d0ccd9d7ac0c_.py @@ -0,0 +1,31 @@ +"""empty message + +Revision ID: d0ccd9d7ac0c +Revises: e7d7ebcea26c +Create Date: 2021-11-22 12:05:31.814178 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'd0ccd9d7ac0c' +down_revision = 'e7d7ebcea26c' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('fido', sa.Column('user_id', sa.Integer(), nullable=True)) + op.create_foreign_key(None, 'fido', 'users', ['user_id'], ['id'], ondelete='cascade') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'fido', type_='foreignkey') + op.drop_column('fido', 'user_id') + # ### end Alembic commands ###