add email_log.mailbox_id column

This commit is contained in:
Son NK 2020-11-24 16:35:16 +01:00
parent bcb2657de3
commit 6b07be5677
2 changed files with 37 additions and 0 deletions

View File

@ -1335,6 +1335,12 @@ class EmailLog(db.Model, ModelMixin):
db.ForeignKey("refused_email.id", ondelete="SET NULL"), nullable=True
)
# in forward phase, this is the mailbox that will receive the email
# in reply phase, this is the mailbox (or a mailbox's authorized address) that sends the email
mailbox_id = db.Column(
db.ForeignKey("mailbox.id", ondelete="cascade"), nullable=True
)
# in case of bounce, record on what mailbox the email has been bounced
# useful when an alias has several mailboxes
bounced_mailbox_id = db.Column(

View File

@ -0,0 +1,31 @@
"""empty message
Revision ID: 623662ea0e7e
Revises: d1edb3cadec8
Create Date: 2020-11-24 16:34:02.327556
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '623662ea0e7e'
down_revision = 'd1edb3cadec8'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('email_log', sa.Column('mailbox_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'email_log', 'mailbox', ['mailbox_id'], ['id'], ondelete='cascade')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'email_log', type_='foreignkey')
op.drop_column('email_log', 'mailbox_id')
# ### end Alembic commands ###