mirror of https://github.com/JohnHammond/CTFd.git
Add cascading delete constraint to DynamicChallenge
parent
818a4568a3
commit
364273f1f1
|
@ -239,7 +239,9 @@ class DynamicValueChallenge(BaseChallenge):
|
|||
|
||||
class DynamicChallenge(Challenges):
|
||||
__mapper_args__ = {"polymorphic_identity": "dynamic"}
|
||||
id = db.Column(None, db.ForeignKey("challenges.id"), primary_key=True)
|
||||
id = db.Column(
|
||||
None, db.ForeignKey("challenges.id", ondelete="CASCADE"), primary_key=True
|
||||
)
|
||||
initial = db.Column(db.Integer, default=0)
|
||||
minimum = db.Column(db.Integer, default=0)
|
||||
decay = db.Column(db.Integer, default=0)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
"""Add cascading delete to dynamic challenges
|
||||
|
||||
Revision ID: b37fb68807ea
|
||||
Revises: 1093835a1051
|
||||
Create Date: 2020-05-06 12:21:39.373983
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b37fb68807ea'
|
||||
down_revision = '1093835a1051'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'dynamic_challenge', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'dynamic_challenge', 'challenges', ['id'], ['id'], ondelete='CASCADE')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'dynamic_challenge', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'dynamic_challenge', 'challenges', ['id'], ['id'])
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue