feat(translate): add insert_method dispatch and model/schema updates for direct DB

This commit is contained in:
2026-06-11 19:12:35 +03:00
parent 1f9040d53e
commit 55604498ae
13 changed files with 249 additions and 251 deletions

View File

@@ -61,6 +61,10 @@ class TranslationJob(Base):
environment_id = Column(String, nullable=True, comment="Superset environment ID for datasource access")
target_database_id = Column(String, nullable=True, comment="Superset database ID for SQL Lab insert target")
# Direct DB insert
insert_method = Column(String, nullable=False, default="sqllab", comment="sqllab|direct_db")
connection_id = Column(String, nullable=True, comment="UUID referencing a DatabaseConnection in GlobalSettings.connections")
created_by = Column(String, nullable=True)
created_at = Column(DateTime, default=lambda: datetime.now(UTC))
updated_at = Column(DateTime, default=lambda: datetime.now(UTC), onupdate=lambda: datetime.now(UTC))
@@ -85,9 +89,11 @@ class TranslationRun(Base):
failed_records = Column(Integer, default=0)
skipped_records = Column(Integer, default=0)
cache_hits = Column(Integer, default=0, comment="Number of rows served from translation cache")
insert_status = Column(String, nullable=True, comment="Status of the Superset insert/update operation")
superset_execution_id = Column(String, nullable=True, comment="Superset execution/task ID")
superset_execution_log = Column(JSON, nullable=True, comment="Superset execution log output")
insert_method = Column(String, nullable=True, comment="sqllab|direct_db — copied from job at run creation")
connection_snapshot = Column(JSON, nullable=True, comment="Snapshot of connection metadata for audit: {name, dialect, host, port, database} — NEVER password")
insert_status = Column(String, nullable=True, comment="Status of the insert/update operation")
superset_execution_id = Column(String, nullable=True, comment="Superset execution/task ID (NULL for direct_db inserts)")
superset_execution_log = Column(JSON, nullable=True, comment="Superset execution log output (NULL for direct_db inserts)")
config_snapshot = Column(JSON, nullable=True, comment="Snapshot of job config at run creation time")
key_hash = Column(String, nullable=True, comment="Hash of source key fields for dedup")
config_hash = Column(String, nullable=True, comment="Hash of translation configuration state")