Update 7ad8508e50de_rename_mathjax_to_katex.py

This commit is contained in:
Groupr 2025-11-27 23:20:57 +00:00
parent 30a62b8721
commit 1ef1c8d621

View file

@ -1,4 +1,4 @@
"""Rename mathjax column to katex in rb_namespace
"""Add katex column in rb_namespace
Revision ID: 7ad8508e50de
Revises: b8f3c9d4e5a1
@ -17,15 +17,14 @@ import sqlalchemy as sa
def upgrade():
# Add new katex column and copy mathjax values
# Keep mathjax column for rollback safety
# Add new katex column with default OFF
op.add_column("rb_namespace", sa.Column("katex", sa.Boolean(), server_default=sa.false()))
# Copy existing mathjax values to katex
op.execute("UPDATE rb_namespace SET katex = mathjax")
# Turn katex ON for any namespace that had mathjax ON
op.execute("UPDATE rb_namespace SET katex = 1 WHERE mathjax = 1")
def downgrade():
# Copy katex values back to mathjax and drop katex column
# Copy katex values back to mathjax
# Note: SQLite doesn't support DROP COLUMN, so we just sync the data back
op.execute("UPDATE rb_namespace SET mathjax = katex")
op.drop_column("rb_namespace", "katex")