From a0784fc711f9e4cb0b22fb22f4b9e8c9b74d3b85 Mon Sep 17 00:00:00 2001 From: Son NK Date: Fri, 20 Mar 2020 12:29:37 +0100 Subject: [PATCH] make aliasUsedOn.user_id non nullable --- app/models.py | 2 +- .../versions/2020_032012_30c13ca016e4_.py | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 migrations/versions/2020_032012_30c13ca016e4_.py diff --git a/app/models.py b/app/models.py index 5325be24..b375a659 100644 --- a/app/models.py +++ b/app/models.py @@ -850,7 +850,7 @@ 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) + user_id = db.Column(db.ForeignKey(User.id, ondelete="cascade"), nullable=False) alias = db.relationship(Alias) diff --git a/migrations/versions/2020_032012_30c13ca016e4_.py b/migrations/versions/2020_032012_30c13ca016e4_.py new file mode 100644 index 00000000..76f92b05 --- /dev/null +++ b/migrations/versions/2020_032012_30c13ca016e4_.py @@ -0,0 +1,33 @@ +"""empty message + +Revision ID: 30c13ca016e4 +Revises: 4e4a759ac4b5 +Create Date: 2020-03-20 12:28:12.901907 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '30c13ca016e4' +down_revision = '4e4a759ac4b5' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('alias_used_on', 'user_id', + existing_type=sa.INTEGER(), + nullable=False) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('alias_used_on', 'user_id', + existing_type=sa.INTEGER(), + nullable=True) + # ### end Alembic commands ###