40 lines
898 B
Python
40 lines
898 B
Python
|
|
"""Change plugins.config column from Text to JSONB.
|
||
|
|
|
||
|
|
The config column was stored as a JSON string in a Text column.
|
||
|
|
This migration converts it to native JSONB for proper querying and validation.
|
||
|
|
|
||
|
|
Revision ID: 0117
|
||
|
|
Revises: 0116
|
||
|
|
"""
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
import sqlalchemy as sa
|
||
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
||
|
|
|
||
|
|
revision = "0117"
|
||
|
|
down_revision = "0116"
|
||
|
|
branch_labels = None
|
||
|
|
depends_on = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
# Convert Text column to JSONB, casting existing JSON strings
|
||
|
|
op.alter_column(
|
||
|
|
"plugins",
|
||
|
|
"config",
|
||
|
|
existing_type=sa.Text(),
|
||
|
|
type_=JSONB,
|
||
|
|
postgresql_using="config::jsonb",
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
# Convert back to Text, casting JSONB to text
|
||
|
|
op.alter_column(
|
||
|
|
"plugins",
|
||
|
|
"config",
|
||
|
|
existing_type=JSONB,
|
||
|
|
type_=sa.Text(),
|
||
|
|
postgresql_using="config::text",
|
||
|
|
)
|