app-MAIL-temp/migrations/versions/2022_070619_b0101a66bb77_add_unsubscribe_behaviour.py
Adrià Casajús f3d47a1eaa
Allow users to keep the original unsub behaviour (#1148)
* Feature: Preserve original unsubscribe request

* Updated tests

* Updated settings

* PR comments

* reduced prefix length

* Include migrate users for new unsub behaviour

* PR comments

Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
2022-07-19 17:25:21 +02:00

31 lines
976 B
Python

"""Add unsubscribe behaviour
Revision ID: b0101a66bb77
Revises: bd7d032087b2
Create Date: 2022-07-06 19:52:04.324761
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = 'b0101a66bb77'
down_revision = 'bd7d032087b2'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('users', sa.Column('unsub_behaviour', sa.Integer(), default=2, server_default='2', nullable=False))
op.execute("UPDATE users SET unsub_behaviour=0 WHERE one_click_unsubscribe_block_sender=false")
op.execute("UPDATE users SET unsub_behaviour=1 WHERE one_click_unsubscribe_block_sender=true")
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'unsub_behaviour')
# ### end Alembic commands ###