From 29afc1b6b5fbbd02f3f454a100b05863407980b2 Mon Sep 17 00:00:00 2001 From: Son Date: Sat, 6 Mar 2021 18:06:29 +0100 Subject: [PATCH] Add Alias.transfer_token col --- app/models.py | 3 ++ .../versions/2021_030618_51bd435bd5cc_.py | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 migrations/versions/2021_030618_51bd435bd5cc_.py diff --git a/app/models.py b/app/models.py index 5d400dcd..01abbff5 100644 --- a/app/models.py +++ b/app/models.py @@ -1003,6 +1003,9 @@ class Alias(db.Model, ModelMixin): # alias is pinned on top pinned = db.Column(db.Boolean, nullable=False, default=False, server_default="0") + # used to transfer an alias to another user + transfer_token = db.Column(db.String(64), default=None, unique=True, nullable=True) + user = db.relationship(User, foreign_keys=[user_id]) mailbox = db.relationship("Mailbox", lazy="joined") diff --git a/migrations/versions/2021_030618_51bd435bd5cc_.py b/migrations/versions/2021_030618_51bd435bd5cc_.py new file mode 100644 index 00000000..b2532759 --- /dev/null +++ b/migrations/versions/2021_030618_51bd435bd5cc_.py @@ -0,0 +1,31 @@ +"""empty message + +Revision ID: 51bd435bd5cc +Revises: e831a883153a +Create Date: 2021-03-06 18:05:34.252719 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '51bd435bd5cc' +down_revision = 'e831a883153a' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('alias', sa.Column('transfer_token', sa.String(length=64), nullable=True)) + op.create_unique_constraint(None, 'alias', ['transfer_token']) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'alias', type_='unique') + op.drop_column('alias', 'transfer_token') + # ### end Alembic commands ###