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
selenium-screenshot-testing
Kevin Chung 2019-07-03 00:04:50 -04:00 committed by GitHub
parent 03058716a0
commit 8b3bb92c9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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()):