mirror of
https://github.com/simple-login/app.git
synced 2025-02-23 15:23:27 +08:00
make sure AliasHibp has cascade ondelete
This commit is contained in:
parent
fb97f384e4
commit
b23e3d94fd
2 changed files with 37 additions and 2 deletions
|
@ -2022,8 +2022,8 @@ class AliasHibp(db.Model, ModelMixin):
|
|||
|
||||
__table_args__ = (db.UniqueConstraint("alias_id", "hibp_id", name="uq_alias_hibp"),)
|
||||
|
||||
alias_id = db.Column(db.Integer(), db.ForeignKey("alias.id"))
|
||||
hibp_id = db.Column(db.Integer(), db.ForeignKey("hibp.id"))
|
||||
alias_id = db.Column(db.Integer(), db.ForeignKey("alias.id", ondelete="cascade"))
|
||||
hibp_id = db.Column(db.Integer(), db.ForeignKey("hibp.id", ondelete="cascade"))
|
||||
|
||||
alias = db.relationship(
|
||||
"Alias", backref=db.backref("alias_hibp", cascade="all, delete-orphan")
|
||||
|
|
35
migrations/versions/2021_052518_68e2f38e33f4_.py
Normal file
35
migrations/versions/2021_052518_68e2f38e33f4_.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 68e2f38e33f4
|
||||
Revises: 6cc7f073b358
|
||||
Create Date: 2021-05-25 18:13:07.614047
|
||||
|
||||
"""
|
||||
import sqlalchemy_utils
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '68e2f38e33f4'
|
||||
down_revision = '6cc7f073b358'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('alias_hibp_hibp_id_fkey', 'alias_hibp', type_='foreignkey')
|
||||
op.drop_constraint('alias_hibp_alias_id_fkey', 'alias_hibp', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'alias_hibp', 'alias', ['alias_id'], ['id'], ondelete='cascade')
|
||||
op.create_foreign_key(None, 'alias_hibp', 'hibp', ['hibp_id'], ['id'], ondelete='cascade')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'alias_hibp', type_='foreignkey')
|
||||
op.drop_constraint(None, 'alias_hibp', type_='foreignkey')
|
||||
op.create_foreign_key('alias_hibp_alias_id_fkey', 'alias_hibp', 'alias', ['alias_id'], ['id'])
|
||||
op.create_foreign_key('alias_hibp_hibp_id_fkey', 'alias_hibp', 'hibp', ['hibp_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in a new issue