20260429_9001_remove_version_columns.py 798 B

12345678910111213141516171819202122
  1. """Remove business version schema artifacts.
  2. Revision ID: 20260429_9001_auth
  3. Revises: 20260428_0004
  4. Create Date: 2026-04-29 00:00:00.000000
  5. """
  6. from alembic import op
  7. revision: str = "20260429_9001_auth"
  8. down_revision: str | None = "20260428_0004"
  9. branch_labels = None
  10. depends_on = None
  11. def upgrade() -> None:
  12. op.execute("DO $$\nDECLARE\n table_record record;\nBEGIN\n FOR table_record IN\n SELECT table_name\n FROM information_schema.columns\n WHERE table_schema = current_schema()\n AND column_name = 'version'\n LOOP\n EXECUTE format('ALTER TABLE %I DROP COLUMN IF EXISTS version', table_record.table_name);\n END LOOP;\nEND $$;")
  13. def downgrade() -> None:
  14. # Business version tables and columns were intentionally removed.
  15. pass