From 6936d9977993bccca9edb20d20f2f83c5885ea89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Casaj=C3=BAs?= Date: Tue, 3 May 2022 14:15:50 +0200 Subject: [PATCH] Set default state for provider complaint --- app/models.py | 4 +- ..._45588d9bb475_store_provider_complaints.py | 36 ------------- ..._28b9b14c9664_store_provider_complaints.py | 50 +++++++++++++++++++ 3 files changed, 53 insertions(+), 37 deletions(-) delete mode 100644 migrations/versions/2022_041916_45588d9bb475_store_provider_complaints.py create mode 100644 migrations/versions/2022_050314_28b9b14c9664_store_provider_complaints.py diff --git a/app/models.py b/app/models.py index 21276207..0054be73 100644 --- a/app/models.py +++ b/app/models.py @@ -3022,7 +3022,9 @@ class ProviderComplaint(Base, ModelMixin): __tablename__ = "provider_complaint" user_id = sa.Column(sa.ForeignKey("users.id"), nullable=False) - state = sa.Column(sa.Integer, nullable=False) + state = sa.Column( + sa.Integer, nullable=False, server_default=str(ProviderComplaintState.new.value) + ) phase = sa.Column( sa.Integer, nullable=False, server_default=str(Phase.unknown.value) ) diff --git a/migrations/versions/2022_041916_45588d9bb475_store_provider_complaints.py b/migrations/versions/2022_041916_45588d9bb475_store_provider_complaints.py deleted file mode 100644 index e5b7e2e9..00000000 --- a/migrations/versions/2022_041916_45588d9bb475_store_provider_complaints.py +++ /dev/null @@ -1,36 +0,0 @@ -"""Store transactional complaints for admins to verify - -Revision ID: 45588d9bb475 -Revises: b500363567e3 -Create Date: 2022-04-19 16:17:42.798792 - -""" -import sqlalchemy_utils -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '45588d9bb475' -down_revision = 'b500363567e3' -branch_labels = None -depends_on = None - -def upgrade(): - op.create_table( - "provider_complaint", - sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), - sa.Column("created_at", sqlalchemy_utils.types.arrow.ArrowType(), nullable=False), - sa.Column("updated_at", sqlalchemy_utils.types.arrow.ArrowType(), nullable=True), - sa.Column("user_id", sa.Integer, nullable=False), - sa.Column("state", sa.Integer, nullable=False), - sa.Column("phase", sa.Integer, nullable=False), - sa.Column("refused_email_id", sa.Integer, nullable=False), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'), - sa.ForeignKeyConstraint(['refused_email_id'], ['refused_email.id'], ondelete='cascade'), - sa.PrimaryKeyConstraint("id"), - ) - - -def downgrade(): - op.drop_table("provider_complaint") diff --git a/migrations/versions/2022_050314_28b9b14c9664_store_provider_complaints.py b/migrations/versions/2022_050314_28b9b14c9664_store_provider_complaints.py new file mode 100644 index 00000000..ee0689d6 --- /dev/null +++ b/migrations/versions/2022_050314_28b9b14c9664_store_provider_complaints.py @@ -0,0 +1,50 @@ +"""store provider complaints + +Revision ID: 28b9b14c9664 +Revises: b500363567e3 +Create Date: 2022-05-03 14:14:23.288929 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "28b9b14c9664" +down_revision = "b500363567e3" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "provider_complaint", + sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), + sa.Column( + "created_at", sqlalchemy_utils.types.arrow.ArrowType(), nullable=False + ), + sa.Column( + "updated_at", sqlalchemy_utils.types.arrow.ArrowType(), nullable=True + ), + sa.Column("user_id", sa.Integer(), nullable=False), + sa.Column("state", sa.Integer(), server_default="0", nullable=False), + sa.Column("phase", sa.Integer(), server_default="0", nullable=False), + sa.Column("refused_email_id", sa.Integer(), nullable=True), + sa.ForeignKeyConstraint( + ["refused_email_id"], ["refused_email.id"], ondelete="cascade" + ), + sa.ForeignKeyConstraint( + ["user_id"], + ["users.id"], + ), + sa.PrimaryKeyConstraint("id"), + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table("provider_complaint") + # ### end Alembic commands ###