From 66c6db773f4ae4f8beb5a2770bc1459e0317be98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Casaj=C3=BAs?= Date: Tue, 3 May 2022 16:47:42 +0200 Subject: [PATCH] Align db with models for the audit_log --- app/models.py | 4 ++- ..._0aaad1740797_store_provider_complaints.py | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 migrations/versions/2022_050316_0aaad1740797_store_provider_complaints.py diff --git a/app/models.py b/app/models.py index 0054be73..575dc373 100644 --- a/app/models.py +++ b/app/models.py @@ -2916,7 +2916,9 @@ class AdminAuditLog(Base): id = sa.Column(sa.Integer, primary_key=True, autoincrement=True) created_at = sa.Column(ArrowType, default=arrow.utcnow, nullable=False) - admin_user_id = sa.Column(sa.ForeignKey("users.id"), nullable=False) + admin_user_id = sa.Column( + sa.ForeignKey("users.id", ondelete="cascade"), nullable=False, index=True + ) action = sa.Column(sa.Integer, nullable=False) model = sa.Column(sa.Text, nullable=False) model_id = sa.Column(sa.Integer, nullable=True) diff --git a/migrations/versions/2022_050316_0aaad1740797_store_provider_complaints.py b/migrations/versions/2022_050316_0aaad1740797_store_provider_complaints.py new file mode 100644 index 00000000..8aaa0363 --- /dev/null +++ b/migrations/versions/2022_050316_0aaad1740797_store_provider_complaints.py @@ -0,0 +1,31 @@ +"""store provider complaints + +Revision ID: 0aaad1740797 +Revises: 28b9b14c9664 +Create Date: 2022-05-03 16:44:24.618504 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '0aaad1740797' +down_revision = '28b9b14c9664' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_index(op.f('ix_admin_audit_log_admin_user_id'), 'admin_audit_log', ['admin_user_id'], unique=False) + op.drop_index('admin_audit_log_admin_user_id_idx', table_name='admin_audit_log') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_index('admin_audit_log_admin_user_id_idx', 'admin_audit_log', ['admin_user_id'], unique=False) + op.drop_index(op.f('ix_admin_audit_log_admin_user_id'), table_name='admin_audit_log') + # ### end Alembic commands ###