2026-07-24 08:19:45 +02:00
|
|
|
"""Add deleted_at column to permissions and share_links tables.
|
|
|
|
|
|
|
|
|
|
The Permission and ShareLink models inherit TenantMixin which includes
|
|
|
|
|
SoftDeleteMixin (deleted_at), but the original plugin migration did not
|
|
|
|
|
create this column. This migration adds it for existing databases.
|
|
|
|
|
|
|
|
|
|
Revision ID: 0031_permissions_soft_delete
|
|
|
|
|
Revises: 0030_contact_merge_history
|
|
|
|
|
Create Date: 2025-07-24
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from alembic import op
|
|
|
|
|
import sqlalchemy as sa
|
|
|
|
|
|
|
|
|
|
# revision identifiers
|
|
|
|
|
revision = "0031_permissions_soft_delete"
|
|
|
|
|
down_revision = "0030_contact_merge_history"
|
|
|
|
|
branch_labels = None
|
|
|
|
|
depends_on = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def upgrade() -> None:
|
|
|
|
|
# Add deleted_at to permissions table (if not exists)
|
2026-07-31 19:16:11 +02:00
|
|
|
op.execute("ALTER TABLE IF EXISTS permissions ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMP WITH TIME ZONE")
|
2026-07-24 08:19:45 +02:00
|
|
|
# Add deleted_at to share_links table (if not exists)
|
2026-07-31 19:16:11 +02:00
|
|
|
op.execute("ALTER TABLE IF EXISTS share_links ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMP WITH TIME ZONE")
|
2026-07-24 08:19:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def downgrade() -> None:
|
|
|
|
|
op.drop_column("share_links", "deleted_at")
|
|
|
|
|
op.drop_column("permissions", "deleted_at")
|