-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
173 additions
and
55 deletions.
There are no files selected for viewing
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
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
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
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
84 changes: 84 additions & 0 deletions
84
migrations/versions/1bd91b02ced3_merge_comment_notification_types.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,84 @@ | ||
"""Merge comment notification types | ||
Revision ID: 1bd91b02ced3 | ||
Revises: 4845fd12dbfd | ||
Create Date: 2020-09-18 02:44:20.827703 | ||
""" | ||
|
||
from alembic import op | ||
from sqlalchemy.dialects import postgresql | ||
from sqlalchemy.sql import column, table | ||
import sqlalchemy as sa | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '1bd91b02ced3' | ||
down_revision = '4845fd12dbfd' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
notification = table( | ||
'notification', | ||
column('eventid', postgresql.UUID()), | ||
column('id', postgresql.UUID()), | ||
column('type', sa.Unicode()), | ||
column('document_uuid', postgresql.UUID()), | ||
column('fragment_uuid', postgresql.UUID()), | ||
) | ||
|
||
project = table( | ||
'project', | ||
column('id', sa.Integer()), | ||
column('uuid', postgresql.UUID()), | ||
column('commentset_id', sa.Integer()), | ||
) | ||
|
||
proposal = table( | ||
'proposal', | ||
column('id', sa.Integer()), | ||
column('uuid', postgresql.UUID()), | ||
column('commentset_id', sa.Integer()), | ||
) | ||
|
||
commentset = table( | ||
'commentset', | ||
column('id', sa.Integer()), | ||
column('uuid', postgresql.UUID()), | ||
) | ||
|
||
|
||
def upgrade(): | ||
op.execute( | ||
notification.update() | ||
.values(type='comment_new', document_uuid=commentset.c.uuid) | ||
.where(notification.c.type == 'comment_project') | ||
.where(notification.c.document_uuid == project.c.uuid) | ||
.where(project.c.commentset_id == commentset.c.id) | ||
) | ||
|
||
op.execute( | ||
notification.update() | ||
.values(type='comment_new', document_uuid=commentset.c.uuid) | ||
.where(notification.c.type == 'comment_proposal') | ||
.where(notification.c.document_uuid == proposal.c.uuid) | ||
.where(proposal.c.commentset_id == commentset.c.id) | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.execute( | ||
notification.update() | ||
.values(type='comment_proposal', document_uuid=proposal.c.uuid) | ||
.where(notification.c.type == 'comment_new') | ||
.where(notification.c.document_uuid == commentset.c.uuid) | ||
.where(proposal.c.commentset_id == commentset.c.id) | ||
) | ||
|
||
op.execute( | ||
notification.update() | ||
.values(type='comment_project', document_uuid=project.c.uuid) | ||
.where(notification.c.type == 'comment_new') | ||
.where(notification.c.document_uuid == commentset.c.uuid) | ||
.where(project.c.commentset_id == commentset.c.id) | ||
) |
43 changes: 43 additions & 0 deletions
43
migrations/versions/3847982f1472_update_comment_notification_preferences.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,43 @@ | ||
"""Update comment notification preferences | ||
Revision ID: 3847982f1472 | ||
Revises: 1bd91b02ced3 | ||
Create Date: 2020-09-18 03:27:44.871342 | ||
""" | ||
|
||
from alembic import op | ||
from sqlalchemy.sql import column, table | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '3847982f1472' | ||
down_revision = '1bd91b02ced3' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
notification_preferences = table( | ||
'notification_preferences', | ||
column('notification_type'), | ||
) | ||
|
||
|
||
def upgrade(): | ||
op.execute( | ||
notification_preferences.update() | ||
.values(notification_type='comment_new') | ||
.where(notification_preferences.c.notification_type == 'comment_project') | ||
) | ||
|
||
op.execute( | ||
notification_preferences.delete().where( | ||
notification_preferences.c.notification_type == 'comment_proposal' | ||
) | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.execute( | ||
notification_preferences.update() | ||
.values(notification_type='comment_project') | ||
.where(notification_preferences.c.notification_type == 'comment_new') | ||
) |