mirror of
https://github.com/aljazceru/CTFd.git
synced 2026-02-01 04:14:25 +01:00
Fix some code and lints
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
"""Add cascading delete to dynamic challenges
|
||||
|
||||
Revision ID: b37fb68807ea
|
||||
Revises: 1093835a1051
|
||||
Revises:
|
||||
Create Date: 2020-05-06 12:21:39.373983
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "b37fb68807ea"
|
||||
down_revision = None
|
||||
@@ -17,7 +14,9 @@ depends_on = None
|
||||
|
||||
def upgrade(op=None):
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint("dynamic_challenge_ibfk_1", "dynamic_challenge", type_="foreignkey")
|
||||
op.drop_constraint(
|
||||
"dynamic_challenge_ibfk_1", "dynamic_challenge", type_="foreignkey"
|
||||
)
|
||||
op.create_foreign_key(
|
||||
None, "dynamic_challenge", "challenges", ["id"], ["id"], ondelete="CASCADE"
|
||||
)
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
import os
|
||||
|
||||
from alembic.migration import MigrationContext
|
||||
from flask import current_app
|
||||
from flask_migrate import Migrate, stamp
|
||||
from sqlalchemy import create_engine
|
||||
from alembic.operations import Operations
|
||||
|
||||
from alembic.script import ScriptDirectory
|
||||
from alembic.config import Config
|
||||
from sqlalchemy import pool
|
||||
|
||||
from CTFd.utils import get_config, set_config
|
||||
|
||||
import inspect
|
||||
import os
|
||||
|
||||
from alembic.config import Config
|
||||
from alembic.migration import MigrationContext
|
||||
from alembic.operations import Operations
|
||||
from alembic.script import ScriptDirectory
|
||||
from flask import current_app
|
||||
from sqlalchemy import create_engine, pool
|
||||
|
||||
from CTFd.utils import get_config, set_config
|
||||
|
||||
|
||||
def upgrade(plugin_name=None):
|
||||
database_url = current_app.config.get("SQLALCHEMY_DATABASE_URI")
|
||||
@@ -24,12 +19,13 @@ def upgrade(plugin_name=None):
|
||||
|
||||
if plugin_name is None:
|
||||
# Get the directory name of the plugin if unspecified
|
||||
caller_path = inspect.stack()[1].filename
|
||||
# Doing it this way doesn't waste the rest of the inspect.stack call
|
||||
frame = inspect.currentframe()
|
||||
caller_info = inspect.getframeinfo(frame.f_back)
|
||||
caller_path = caller_info[0]
|
||||
plugin_name = os.path.basename(os.path.dirname(caller_path))
|
||||
|
||||
engine = create_engine(
|
||||
database_url, poolclass=pool.NullPool
|
||||
)
|
||||
engine = create_engine(database_url, poolclass=pool.NullPool)
|
||||
conn = engine.connect()
|
||||
context = MigrationContext.configure(conn)
|
||||
op = Operations(context)
|
||||
|
||||
Reference in New Issue
Block a user