Align db with models for the audit_log

This commit is contained in:
Adrià Casajús 2022-05-03 16:47:42 +02:00
parent eea436875a
commit 66c6db773f
No known key found for this signature in database
GPG Key ID: F0033226A5AFC9B9
2 changed files with 34 additions and 1 deletions

View File

@ -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)

View File

@ -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 ###