Files
opsxsql/backend/app/models/instance.py
T
logan d5d19d6be4 feat: 项目重命名 SQL-Platform + 数据源表单重写(连接模式/流程/排除DB/脱敏)
- 项目名称 Web-Lite Pro → SQL-Platform 全局替换(13处)
- Instance 模型新增: access_mode, workflow, excluded_databases, mask_fields
- 创建数据源表单: 分区卡片(数据源信息/连接模式/流程/高级配置)
- 后端 JSON 字段序列化/反序列化
- 新增 5 个 Instance 字段测试 (133 total)
2026-05-22 22:08:05 +08:00

30 lines
1.4 KiB
Python

from sqlalchemy import Column, Integer, String, Text, DateTime, func
from app.core.database import Base
class Instance(Base):
__tablename__ = "instances"
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(100), nullable=False)
db_type = Column(String(20), nullable=False) # mysql / postgres / redis / mongo
host = Column(String(200), nullable=False)
port = Column(Integer, nullable=False)
username = Column(String(100), nullable=False)
password = Column(String(500), nullable=False) # encrypted
database = Column(String(100), nullable=True)
env = Column(String(20), default="development") # production / staging / development
description = Column(Text, nullable=True)
status = Column(String(20), default="disconnected") # connected / disconnected / error
version = Column(String(50), nullable=True)
# 新增字段
access_mode = Column(String(20), default="readwrite") # readwrite / read / write
workflow = Column(Text, nullable=True) # JSON: [{stage, role, assignee}]
excluded_databases = Column(Text, nullable=True) # JSON: ["sys", "information_schema", ...]
mask_fields = Column(Text, nullable=True) # JSON: [{table, field, rule}]
created_at = Column(DateTime, server_default=func.now())
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())