feat: 增加公告栏并让用户自选学时判断

This commit is contained in:
Nixevol
2026-11-19 04:08:30 +08:00
parent 3fe6d4c111
commit 4d4fe224bc
20 changed files with 789 additions and 64 deletions
@@ -0,0 +1,32 @@
"""账号自选学时判断依据,并增加公告。"""
from alembic import op
import sqlalchemy as sa
revision = "0015_account_source_and_notices"
down_revision = "0014_official_month_hours"
branch_labels = None
depends_on = None
def upgrade() -> None:
with op.batch_alter_table("accounts") as batch:
batch.add_column(sa.Column("hours_source", sa.String(length=16), server_default="api", nullable=False))
op.execute(
"UPDATE accounts SET hours_source = COALESCE("
"(SELECT hours_source FROM system_config ORDER BY id LIMIT 1), 'api')"
)
op.create_table(
"announcements",
sa.Column("id", sa.Integer(), primary_key=True),
sa.Column("title", sa.String(length=80), nullable=False),
sa.Column("body", sa.Text(), nullable=False),
sa.Column("link_url", sa.String(length=300), server_default="", nullable=False),
sa.Column("published_at", sa.DateTime(timezone=True), nullable=False),
)
def downgrade() -> None:
op.drop_table("announcements")
with op.batch_alter_table("accounts") as batch:
batch.drop_column("hours_source")