Add AliasUsedOn.user_id col

This commit is contained in:
Son NK 2020-03-20 12:13:00 +01:00 committed by Son NK
parent 4f1e4d3781
commit b655503d39
2 changed files with 34 additions and 0 deletions

View file

@ -850,6 +850,9 @@ class AliasUsedOn(db.Model, ModelMixin):
)
alias_id = db.Column(db.ForeignKey(Alias.id, ondelete="cascade"), nullable=False)
user_id = db.Column(db.ForeignKey(User.id, ondelete="cascade"), nullable=True)
alias = db.relationship(Alias)
hostname = db.Column(db.String(1024), nullable=False)

View file

@ -0,0 +1,31 @@
"""empty message
Revision ID: 4e4a759ac4b5
Revises: dbd80d290f04
Create Date: 2020-03-20 12:12:45.699045
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4e4a759ac4b5'
down_revision = 'dbd80d290f04'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('alias_used_on', sa.Column('user_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'alias_used_on', 'users', ['user_id'], ['id'], ondelete='cascade')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'alias_used_on', type_='foreignkey')
op.drop_column('alias_used_on', 'user_id')
# ### end Alembic commands ###