feat: add ER diagram and enhance TableStructure with FK details, triggers, comments
- Add interactive ER diagram with ReactFlow + dagre auto-layout, accessible via right-click context menu on schema nodes in the sidebar - Enhance TableStructure: column comments, FK referenced table/columns, ON UPDATE/DELETE rules, new Triggers tab - Backend: rewrite get_table_constraints using pg_constraint for proper composite FK support, add get_table_triggers and get_schema_erd commands Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ pub struct ColumnInfo {
|
||||
pub ordinal_position: i32,
|
||||
pub character_maximum_length: Option<i32>,
|
||||
pub is_primary_key: bool,
|
||||
pub comment: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -34,6 +35,11 @@ pub struct ConstraintInfo {
|
||||
pub name: String,
|
||||
pub constraint_type: String,
|
||||
pub columns: Vec<String>,
|
||||
pub referenced_schema: Option<String>,
|
||||
pub referenced_table: Option<String>,
|
||||
pub referenced_columns: Option<Vec<String>>,
|
||||
pub update_rule: Option<String>,
|
||||
pub delete_rule: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -43,3 +49,48 @@ pub struct IndexInfo {
|
||||
pub is_unique: bool,
|
||||
pub is_primary: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct TriggerInfo {
|
||||
pub name: String,
|
||||
pub event: String,
|
||||
pub timing: String,
|
||||
pub orientation: String,
|
||||
pub function_name: String,
|
||||
pub is_enabled: bool,
|
||||
pub definition: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ErdColumn {
|
||||
pub name: String,
|
||||
pub data_type: String,
|
||||
pub is_nullable: bool,
|
||||
pub is_primary_key: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ErdTable {
|
||||
pub schema: String,
|
||||
pub name: String,
|
||||
pub columns: Vec<ErdColumn>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ErdRelationship {
|
||||
pub constraint_name: String,
|
||||
pub source_schema: String,
|
||||
pub source_table: String,
|
||||
pub source_columns: Vec<String>,
|
||||
pub target_schema: String,
|
||||
pub target_table: String,
|
||||
pub target_columns: Vec<String>,
|
||||
pub update_rule: String,
|
||||
pub delete_rule: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ErdData {
|
||||
pub tables: Vec<ErdTable>,
|
||||
pub relationships: Vec<ErdRelationship>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user