Files
aitsc/migrations/versions/a1b2c3d4e5f6_add_prompt_template_admin_fields.py
renjianbo 3b806e2bde refactor: project restructuring - migrate to modular directory layout
- Move root-level docs into docs/ directory
- Move config files into config/ directory
- Move docker files into docker/ directory
- Move test scripts into tests/ directory
- Remove .env from tracking (use .env.example as template)
- Remove .venv/ from tracking (use requirements.txt)
- Add Vue3 frontend app (vue-app/)
- Add new routes: upload, user_templates, meeting_minutes, etc.
- Add database migrations for prompt_template additions
- Fix load_dotenv() to use absolute path for Flask reloader compatibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-13 22:34:53 +08:00

61 lines
1.7 KiB
Python

"""add prompt_template is_active, sort_order, usage_count, updated_at
Revision ID: a1b2c3d4e5f6
Revises: f3a8c9012abc
Create Date: 2026-05-03
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import inspect
revision = "a1b2c3d4e5f6"
down_revision = "f3a8c9012abc"
branch_labels = None
depends_on = None
def _prompt_template_columns(bind):
try:
return {c["name"] for c in inspect(bind).get_columns("prompt_template")}
except Exception:
return set()
def upgrade():
bind = op.get_bind()
cols = _prompt_template_columns(bind)
if "is_active" not in cols:
op.add_column(
"prompt_template",
sa.Column("is_active", sa.Boolean(), nullable=True, server_default=sa.text("1")),
)
if "sort_order" not in cols:
op.add_column(
"prompt_template",
sa.Column("sort_order", sa.Integer(), nullable=True, server_default=sa.text("0")),
)
if "usage_count" not in cols:
op.add_column(
"prompt_template",
sa.Column("usage_count", sa.Integer(), nullable=True, server_default=sa.text("0")),
)
if "updated_at" not in cols:
op.add_column(
"prompt_template",
sa.Column("updated_at", sa.DateTime(), nullable=True),
)
def downgrade():
bind = op.get_bind()
cols = _prompt_template_columns(bind)
if "updated_at" in cols:
op.drop_column("prompt_template", "updated_at")
if "usage_count" in cols:
op.drop_column("prompt_template", "usage_count")
if "sort_order" in cols:
op.drop_column("prompt_template", "sort_order")
if "is_active" in cols:
op.drop_column("prompt_template", "is_active")