Squashed 'core/' content from commit 92ec910
git-subtree-dir: core git-subtree-split: 92ec910a132e379a3a6e442a75bcb07cac0f0010
This commit is contained in:
41
backend/alembic/versions/002_add_system_settings.py
Normal file
41
backend/alembic/versions/002_add_system_settings.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""Add system_settings table
|
||||
|
||||
Revision ID: 002_system_settings
|
||||
Revises: 001_initial
|
||||
Create Date: 2026-04-02
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "002_system_settings"
|
||||
down_revision = "001_initial"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
"system_settings",
|
||||
sa.Column("id", sa.Integer, primary_key=True, autoincrement=True),
|
||||
sa.Column("key", sa.String(100), unique=True, nullable=False, index=True),
|
||||
sa.Column("value", sa.Text, nullable=False, server_default=""),
|
||||
sa.Column("description", sa.String(255)),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
|
||||
)
|
||||
|
||||
# Seed default settings
|
||||
op.execute("""
|
||||
INSERT INTO system_settings (key, value, description) VALUES
|
||||
('platform_name', '天普零碳园区智慧能源管理平台', '平台名称'),
|
||||
('data_retention_days', '365', '数据保留天数'),
|
||||
('alarm_auto_resolve_minutes', '30', '告警自动解除时间(分钟)'),
|
||||
('simulator_interval_seconds', '15', '模拟器采集间隔(秒)'),
|
||||
('notification_email_enabled', 'false', '是否启用邮件通知'),
|
||||
('notification_email_smtp', '', 'SMTP服务器地址'),
|
||||
('report_auto_schedule_enabled', 'false', '是否启用自动报表'),
|
||||
('timezone', 'Asia/Shanghai', '系统时区')
|
||||
""")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_table("system_settings")
|
||||
Reference in New Issue
Block a user