add forward_email table

This commit is contained in:
Son NK 2019-11-07 17:34:18 +01:00
parent 7949bae207
commit c1ac71abac
2 changed files with 60 additions and 0 deletions

View File

@ -520,3 +520,24 @@ class ClientUser(db.Model, ModelMixin):
res[Scope.EMAIL.value] = self.user.email
return res
class ForwardEmail(db.Model, ModelMixin):
"""
Emails that are forwarded through SL: email that is sent by website to user via SL alias
"""
__table_args__ = (
db.UniqueConstraint("gen_email_id", "website_email", name="uq_forward_email"),
)
gen_email_id = db.Column(
db.ForeignKey(GenEmail.id, ondelete="cascade"), nullable=False
)
website_email = db.Column(db.String(128), nullable=False)
# when user clicks on "reply", they will reply to this address.
# This address allows to hide user personal email
# this reply email is created every time a website sends an email to user
# it has the prefix "reply+" to distinguish with other email
reply_email = db.Column(db.String(128), nullable=False)

View File

@ -0,0 +1,39 @@
"""empty message
Revision ID: 5fa68bafae72
Revises: c79c702a1f23
Create Date: 2019-11-07 17:32:32.358891
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5fa68bafae72'
down_revision = 'c79c702a1f23'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('forward_email',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
sa.Column('gen_email_id', sa.Integer(), nullable=False),
sa.Column('website_email', sa.String(length=128), nullable=False),
sa.Column('reply_email', sa.String(length=128), nullable=False),
sa.ForeignKeyConstraint(['gen_email_id'], ['gen_email.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('gen_email_id', 'website_email', name='uq_forward_email')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('forward_email')
# ### end Alembic commands ###