fix(faq): repair category schema and icons
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""add faq category icon column
|
||||
|
||||
Revision ID: 20260608_01
|
||||
Revises: 20260529_04
|
||||
Create Date: 2026-06-08 14:30:00.000000
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision: str = "20260608_01"
|
||||
down_revision: Union[str, None] = "20260529_04"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def _column_exists(inspector: sa.Inspector, table_name: str, column_name: str) -> bool:
|
||||
return any(column["name"] == column_name for column in inspector.get_columns(table_name))
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
inspector = sa.inspect(bind)
|
||||
if "faq_categories" in inspector.get_table_names() and not _column_exists(inspector, "faq_categories", "icon"):
|
||||
op.add_column("faq_categories", sa.Column("icon", sa.String(length=30), nullable=True))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
inspector = sa.inspect(bind)
|
||||
if "faq_categories" in inspector.get_table_names() and _column_exists(inspector, "faq_categories", "icon"):
|
||||
op.drop_column("faq_categories", "icon")
|
||||
Reference in New Issue
Block a user