add gen_email.custom_domain_id foreign key

This commit is contained in:
Son NK 2019-12-02 00:28:50 +00:00
parent 86cc9b18aa
commit 24cb2688ca
2 changed files with 35 additions and 0 deletions

View File

@ -402,6 +402,10 @@ class GenEmail(db.Model, ModelMixin):
# this email has been customized by user, i.e. not generated randomly
custom = db.Column(db.Boolean(), default=False, nullable=False, server_default="0")
custom_domain_id = db.Column(
db.ForeignKey("custom_domain.id", ondelete="cascade"), nullable=True
)
user = db.relationship(User)
@classmethod

View File

@ -0,0 +1,31 @@
"""empty message
Revision ID: 5e868298fee7
Revises: 0b28518684ae
Create Date: 2019-12-02 00:28:40.281432
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5e868298fee7'
down_revision = '0b28518684ae'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('gen_email', sa.Column('custom_domain_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'gen_email', 'custom_domain', ['custom_domain_id'], ['id'], ondelete='cascade')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'gen_email', type_='foreignkey')
op.drop_column('gen_email', 'custom_domain_id')
# ### end Alembic commands ###