mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +01:00
Only add team_captain_id foreign key if the db backend isn't SQLite (#1048)
* Only add `teams.team_captain_id` foreign key if the db backend isn't SQLite. SQLite does not support ALTER for the manipulation of columns/constraints. * Closes #1041
This commit is contained in:
@@ -30,7 +30,11 @@ users_table = table('users',
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('teams', sa.Column('captain_id', sa.Integer(), nullable=True))
|
||||
op.create_foreign_key('team_captain_id', 'teams', 'users', ['captain_id'], ['id'])
|
||||
|
||||
bind = op.get_bind()
|
||||
url = str(bind.engine.url)
|
||||
if url.startswith('sqlite') is False:
|
||||
op.create_foreign_key('team_captain_id', 'teams', 'users', ['captain_id'], ['id'])
|
||||
|
||||
connection = op.get_bind()
|
||||
for team in connection.execute(teams_table.select()):
|
||||
|
||||
Reference in New Issue
Block a user