1
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
"""Add new system configs: user_agreement_privacy_url and site_copyright
|
||||
|
||||
Revision ID: 000_add_new_configs
|
||||
Revises:
|
||||
Create Date: 2024-01-01 00:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import text
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '000_add_new_configs'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
conn = op.get_bind()
|
||||
|
||||
# Add user_agreement_privacy_url if not exists
|
||||
result = conn.execute(text("SELECT COUNT(*) FROM system_configs WHERE key = 'user_agreement_privacy_url'"))
|
||||
if result.scalar() == 0:
|
||||
conn.execute(text("""
|
||||
INSERT INTO system_configs (id, key, value, description, created_at, updated_at)
|
||||
VALUES (SUBSTRING(MD5(RAND()) FROM 1 FOR 32), 'user_agreement_privacy_url', '', '用户协议及隐私政策PDF文件', NOW(), NOW())
|
||||
"""))
|
||||
|
||||
# Add site_copyright if not exists
|
||||
result = conn.execute(text("SELECT COUNT(*) FROM system_configs WHERE key = 'site_copyright'"))
|
||||
if result.scalar() == 0:
|
||||
conn.execute(text("""
|
||||
INSERT INTO system_configs (id, key, value, description, created_at, updated_at)
|
||||
VALUES (SUBSTRING(MD5(RAND()) FROM 1 FOR 32), 'site_copyright', '© 2024 民众智创 版权所有', '网站底部版权信息', NOW(), NOW())
|
||||
"""))
|
||||
|
||||
|
||||
def downgrade():
|
||||
conn = op.get_bind()
|
||||
conn.execute(text("DELETE FROM system_configs WHERE key IN ('user_agreement_privacy_url', 'site_copyright')"))
|
||||
Reference in New Issue
Block a user