diff --git a/app/models.py b/app/models.py index f1e9f3bb..32c7802c 100644 --- a/app/models.py +++ b/app/models.py @@ -1483,6 +1483,9 @@ class EmailLog(db.Model, ModelMixin): contact_id = db.Column( db.ForeignKey(Contact.id, ondelete="cascade"), nullable=False, index=True ) + alias_id = db.Column( + db.ForeignKey(Alias.id, ondelete="cascade"), nullable=True, index=True + ) # whether this is a reply is_reply = db.Column(db.Boolean, nullable=False, default=False) diff --git a/migrations/versions/2021_071112_f3f19998b755_.py b/migrations/versions/2021_071112_f3f19998b755_.py new file mode 100644 index 00000000..cc1c8ade --- /dev/null +++ b/migrations/versions/2021_071112_f3f19998b755_.py @@ -0,0 +1,33 @@ +"""empty message + +Revision ID: f3f19998b755 +Revises: 8e70205a5308 +Create Date: 2021-07-11 12:26:31.267912 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'f3f19998b755' +down_revision = '8e70205a5308' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('email_log', sa.Column('alias_id', sa.Integer(), nullable=True)) + op.create_index(op.f('ix_email_log_alias_id'), 'email_log', ['alias_id'], unique=False) + op.create_foreign_key(None, 'email_log', 'alias', ['alias_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_index(op.f('ix_email_log_alias_id'), table_name='email_log') + op.drop_column('email_log', 'alias_id') + # ### end Alembic commands ###