From 5b9f3c2763da22da5ac102ed5368fab3f7d1dd50 Mon Sep 17 00:00:00 2001 From: Son NK Date: Sat, 28 Mar 2020 19:05:27 +0100 Subject: [PATCH] add contact.is_cc column --- app/models.py | 6 ++++ .../versions/2020_032223_67c61eead8d2_.py | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 migrations/versions/2020_032223_67c61eead8d2_.py diff --git a/app/models.py b/app/models.py index 0068e986..7999b28d 100644 --- a/app/models.py +++ b/app/models.py @@ -729,6 +729,9 @@ class Contact(db.Model, ModelMixin): # it has the prefix "reply+" to distinguish with other email reply_email = db.Column(db.String(512), nullable=False) + # whether a contact is created via CC + is_cc = db.Column(db.Boolean, nullable=False, default=False, server_default="0") + alias = db.relationship(Alias, backref="contacts") def website_send_to(self): @@ -757,6 +760,9 @@ class Contact(db.Model, ModelMixin): .first() ) + def __repr__(self): + return f"" + class EmailLog(db.Model, ModelMixin): user_id = db.Column(db.ForeignKey(User.id, ondelete="cascade"), nullable=False) diff --git a/migrations/versions/2020_032223_67c61eead8d2_.py b/migrations/versions/2020_032223_67c61eead8d2_.py new file mode 100644 index 00000000..9bb6a08e --- /dev/null +++ b/migrations/versions/2020_032223_67c61eead8d2_.py @@ -0,0 +1,29 @@ +"""empty message + +Revision ID: 67c61eead8d2 +Revises: 541ce53ab6e9 +Create Date: 2020-03-22 23:58:02.672562 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '67c61eead8d2' +down_revision = '541ce53ab6e9' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('contact', sa.Column('is_cc', sa.Boolean(), server_default='0', nullable=False)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('contact', 'is_cc') + # ### end Alembic commands ###