From db4eb69843407508c2c47d003f9f4c99b537fbcf Mon Sep 17 00:00:00 2001 From: Carlos Quintana <74399022+cquintana92@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:52:15 +0100 Subject: [PATCH] revert: deleted alias user id model and migration (#2306) --- app/models.py | 6 ---- ...210efa3_revert_user_id_in_deleted_alias.py | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 migrations/versions/2024_110612_bc9aa210efa3_revert_user_id_in_deleted_alias.py diff --git a/app/models.py b/app/models.py index f92a6db7..702e8752 100644 --- a/app/models.py +++ b/app/models.py @@ -2306,12 +2306,6 @@ class DeletedAlias(Base, ModelMixin): server_default=str(AliasDeleteReason.Unspecified.value), ) - user_id = sa.Column(sa.Integer, nullable=True, default=None, server_default=None) - - __table_args__ = ( - sa.Index("ix_deleted_alias_user_id_created_at", "user_id", "created_at"), - ) - @classmethod def create(cls, **kw): raise Exception("should use delete_alias(alias,user) instead") diff --git a/migrations/versions/2024_110612_bc9aa210efa3_revert_user_id_in_deleted_alias.py b/migrations/versions/2024_110612_bc9aa210efa3_revert_user_id_in_deleted_alias.py new file mode 100644 index 00000000..8de4ae27 --- /dev/null +++ b/migrations/versions/2024_110612_bc9aa210efa3_revert_user_id_in_deleted_alias.py @@ -0,0 +1,28 @@ +"""Revert user id on deleted alias + +Revision ID: bc9aa210efa3 +Revises: 4882cc49dde9 +Create Date: 2024-11-06 12:44:44.129691 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'bc9aa210efa3' +down_revision = '4882cc49dde9' +branch_labels = None +depends_on = None + + +def upgrade(): + with op.get_context().autocommit_block(): + op.drop_index('ix_deleted_alias_user_id_created_at', table_name='deleted_alias') + op.drop_column('deleted_alias', 'user_id') + + +def downgrade(): + op.add_column('deleted_alias', sa.Column('user_id', sa.Integer(), server_default=None, nullable=True)) + with op.get_context().autocommit_block(): + op.create_index('ix_deleted_alias_user_id_created_at', 'deleted_alias', ['user_id', 'created_at'], unique=False, postgresql_concurrently=True)