-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set NULL autokarma on Updates to True if auto_karma is non-NULL.
fixes #950
- Loading branch information
1 parent
cdd824f
commit a8843a7
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
alembic/versions/5110dfc1a01a_set_autokarma_to_true_for_updates_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Set NULL autokarma to True for Updates that have non-NULL stable karma thresholds. | ||
Revision ID: 5110dfc1a01a | ||
Revises: 37f38ddc4c8d | ||
Create Date: 2016-09-24 02:53:42.025785 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '5110dfc1a01a' | ||
down_revision = '37f38ddc4c8d' | ||
|
||
|
||
def upgrade(): | ||
"""Set NULL autokarma to True for Updates that have non-NULL stable karma thresholds.""" | ||
# Build a fake mini version of the updates table so we can form an UPDATE statement. | ||
updates = sa.sql.table('updates', sa.sql.column('autokarma', sa.Boolean), | ||
sa.sql.column('stable_karma', sa.Integer)) | ||
# Set autokarma to True if there is a stable threshold set and autokarma is None. | ||
op.execute( | ||
updates.update().where( | ||
updates.c.stable_karma != None).where(updates.c.autokarma == None).values( | ||
{'autokarma': True})) | ||
|
||
|
||
def downgrade(): | ||
"""There isn't a way to downgrade this migration.""" | ||
pass |