feat(ui): 🎉 Add GUID field to column, database, schema, and table editors
Some checks failed
CI / Test (1.24) (push) Successful in -27m38s
CI / Lint (push) Successful in -27m58s
CI / Test (1.25) (push) Successful in -26m52s
CI / Build (push) Successful in -28m9s
Integration Tests / Integration Tests (push) Failing after -28m11s

This commit is contained in:
2026-01-04 20:00:18 +02:00
parent b4ff4334cc
commit 19fba62f1b
4 changed files with 49 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ func (se *SchemaEditor) showColumnEditor(schemaIndex, tableIndex, colIndex int,
newIsNotNull := column.NotNull newIsNotNull := column.NotNull
newDefault := column.Default newDefault := column.Default
newDescription := column.Description newDescription := column.Description
newGUID := column.GUID
// Column type options: PostgreSQL, MySQL, SQL Server, and common SQL types // Column type options: PostgreSQL, MySQL, SQL Server, and common SQL types
columnTypes := []string{ columnTypes := []string{
@@ -94,9 +95,14 @@ func (se *SchemaEditor) showColumnEditor(schemaIndex, tableIndex, colIndex int,
newDescription = value newDescription = value
}) })
form.AddInputField("GUID", column.GUID, 40, nil, func(value string) {
newGUID = value
})
form.AddButton("Save", func() { form.AddButton("Save", func() {
// Apply changes using dataops // Apply changes using dataops
se.UpdateColumn(schemaIndex, tableIndex, originalName, newName, newType, newIsPK, newIsNotNull, newDefault, newDescription) se.UpdateColumn(schemaIndex, tableIndex, originalName, newName, newType, newIsPK, newIsNotNull, newDefault, newDescription)
se.db.Schemas[schemaIndex].Tables[tableIndex].Columns[newName].GUID = newGUID
se.pages.RemovePage("column-editor") se.pages.RemovePage("column-editor")
se.pages.SwitchToPage("table-editor") se.pages.SwitchToPage("table-editor")

View File

@@ -14,6 +14,7 @@ func (se *SchemaEditor) showEditDatabaseForm() {
dbComment := se.db.Comment dbComment := se.db.Comment
dbType := string(se.db.DatabaseType) dbType := string(se.db.DatabaseType)
dbVersion := se.db.DatabaseVersion dbVersion := se.db.DatabaseVersion
dbGUID := se.db.GUID
// Database type options // Database type options
dbTypeOptions := []string{"pgsql", "mssql", "sqlite"} dbTypeOptions := []string{"pgsql", "mssql", "sqlite"}
@@ -45,11 +46,16 @@ func (se *SchemaEditor) showEditDatabaseForm() {
dbVersion = value dbVersion = value
}) })
form.AddInputField("GUID", dbGUID, 40, nil, func(value string) {
dbGUID = value
})
form.AddButton("Save", func() { form.AddButton("Save", func() {
if dbName == "" { if dbName == "" {
return return
} }
se.updateDatabase(dbName, dbDescription, dbComment, dbType, dbVersion) se.updateDatabase(dbName, dbDescription, dbComment, dbType, dbVersion)
se.db.GUID = dbGUID
se.pages.RemovePage("edit-database") se.pages.RemovePage("edit-database")
se.pages.RemovePage("main") se.pages.RemovePage("main")
se.pages.AddPage("main", se.createMainMenu(), true, true) se.pages.AddPage("main", se.createMainMenu(), true, true)

View File

@@ -24,8 +24,8 @@ func (se *SchemaEditor) showSchemaList() {
schemaTable := tview.NewTable().SetBorders(true).SetSelectable(true, false).SetFixed(1, 0) schemaTable := tview.NewTable().SetBorders(true).SetSelectable(true, false).SetFixed(1, 0)
// Add header row with padding for full width // Add header row with padding for full width
headers := []string{"Name", "Sequence", "Total Tables", "Total Sequences", "Total Views", "Description"} headers := []string{"Name", "Sequence", "Total Tables", "Total Sequences", "Total Views", "GUID", "Description"}
headerWidths := []int{20, 15, 20, 20, 15} // Last column takes remaining space headerWidths := []int{20, 15, 20, 20, 15, 36} // Last column takes remaining space
for i, header := range headers { for i, header := range headers {
padding := "" padding := ""
if i < len(headerWidths) { if i < len(headerWidths) {
@@ -67,9 +67,14 @@ func (se *SchemaEditor) showSchemaList() {
viewsCell := tview.NewTableCell(viewsStr).SetSelectable(true) viewsCell := tview.NewTableCell(viewsStr).SetSelectable(true)
schemaTable.SetCell(row+1, 4, viewsCell) schemaTable.SetCell(row+1, 4, viewsCell)
// GUID - pad to 36 chars
guidStr := fmt.Sprintf("%-36s", schema.GUID)
guidCell := tview.NewTableCell(guidStr).SetSelectable(true)
schemaTable.SetCell(row+1, 5, guidCell)
// Description - no padding, takes remaining space // Description - no padding, takes remaining space
descCell := tview.NewTableCell(schema.Description).SetSelectable(true) descCell := tview.NewTableCell(schema.Description).SetSelectable(true)
schemaTable.SetCell(row+1, 5, descCell) schemaTable.SetCell(row+1, 6, descCell)
} }
schemaTable.SetTitle(" Schemas ").SetBorder(true).SetTitleAlign(tview.AlignLeft) schemaTable.SetTitle(" Schemas ").SetBorder(true).SetTitleAlign(tview.AlignLeft)
@@ -307,6 +312,7 @@ func (se *SchemaEditor) showEditSchemaDialog(schemaIndex int) {
newName := schema.Name newName := schema.Name
newOwner := schema.Owner newOwner := schema.Owner
newDescription := schema.Description newDescription := schema.Description
newGUID := schema.GUID
form.AddInputField("Schema Name", schema.Name, 40, nil, func(value string) { form.AddInputField("Schema Name", schema.Name, 40, nil, func(value string) {
newName = value newName = value
@@ -320,9 +326,14 @@ func (se *SchemaEditor) showEditSchemaDialog(schemaIndex int) {
newDescription = value newDescription = value
}) })
form.AddInputField("GUID", schema.GUID, 40, nil, func(value string) {
newGUID = value
})
form.AddButton("Save", func() { form.AddButton("Save", func() {
// Apply changes using dataops // Apply changes using dataops
se.UpdateSchema(schemaIndex, newName, newOwner, newDescription) se.UpdateSchema(schemaIndex, newName, newOwner, newDescription)
se.db.Schemas[schemaIndex].GUID = newGUID
schema := se.db.Schemas[schemaIndex] schema := se.db.Schemas[schemaIndex]
se.pages.RemovePage("edit-schema") se.pages.RemovePage("edit-schema")

View File

@@ -24,8 +24,8 @@ func (se *SchemaEditor) showTableList() {
tableTable := tview.NewTable().SetBorders(true).SetSelectable(true, false).SetFixed(1, 0) tableTable := tview.NewTable().SetBorders(true).SetSelectable(true, false).SetFixed(1, 0)
// Add header row with padding for full width // Add header row with padding for full width
headers := []string{"Name", "Schema", "Sequence", "Total Columns", "Total Relations", "Total Indexes", "Description", "Comment"} headers := []string{"Name", "Schema", "Sequence", "Total Columns", "Total Relations", "Total Indexes", "GUID", "Description", "Comment"}
headerWidths := []int{18, 15, 12, 14, 15, 14, 0, 12} // Description gets remainder headerWidths := []int{18, 15, 12, 14, 15, 14, 36, 0, 12} // Description gets remainder
for i, header := range headers { for i, header := range headers {
padding := "" padding := ""
if i < len(headerWidths) && headerWidths[i] > 0 { if i < len(headerWidths) && headerWidths[i] > 0 {
@@ -82,14 +82,19 @@ func (se *SchemaEditor) showTableList() {
idxCell := tview.NewTableCell(idxStr).SetSelectable(true) idxCell := tview.NewTableCell(idxStr).SetSelectable(true)
tableTable.SetCell(row+1, 5, idxCell) tableTable.SetCell(row+1, 5, idxCell)
// GUID - pad to 36 chars
guidStr := fmt.Sprintf("%-36s", table.GUID)
guidCell := tview.NewTableCell(guidStr).SetSelectable(true)
tableTable.SetCell(row+1, 6, guidCell)
// Description - no padding, takes remaining space // Description - no padding, takes remaining space
descCell := tview.NewTableCell(table.Description).SetSelectable(true) descCell := tview.NewTableCell(table.Description).SetSelectable(true)
tableTable.SetCell(row+1, 6, descCell) tableTable.SetCell(row+1, 7, descCell)
// Comment - pad to 12 chars // Comment - pad to 12 chars
commentStr := fmt.Sprintf("%-12s", table.Comment) commentStr := fmt.Sprintf("%-12s", table.Comment)
commentCell := tview.NewTableCell(commentStr).SetSelectable(true) commentCell := tview.NewTableCell(commentStr).SetSelectable(true)
tableTable.SetCell(row+1, 7, commentCell) tableTable.SetCell(row+1, 8, commentCell)
} }
tableTable.SetTitle(" All Tables ").SetBorder(true).SetTitleAlign(tview.AlignLeft) tableTable.SetTitle(" All Tables ").SetBorder(true).SetTitleAlign(tview.AlignLeft)
@@ -188,8 +193,8 @@ func (se *SchemaEditor) showTableEditor(schemaIndex, tableIndex int, table *mode
colTable := tview.NewTable().SetBorders(true).SetSelectable(true, false).SetFixed(1, 0) colTable := tview.NewTable().SetBorders(true).SetSelectable(true, false).SetFixed(1, 0)
// Add header row with padding for full width // Add header row with padding for full width
headers := []string{"Name", "Type", "Default", "KeyType", "Description"} headers := []string{"Name", "Type", "Default", "KeyType", "GUID", "Description"}
headerWidths := []int{20, 18, 15, 15} // Last column takes remaining space headerWidths := []int{20, 18, 15, 15, 36} // Last column takes remaining space
for i, header := range headers { for i, header := range headers {
padding := "" padding := ""
if i < len(headerWidths) { if i < len(headerWidths) {
@@ -237,9 +242,14 @@ func (se *SchemaEditor) showTableEditor(schemaIndex, tableIndex int, table *mode
keyTypeCell := tview.NewTableCell(keyTypeStr).SetSelectable(true) keyTypeCell := tview.NewTableCell(keyTypeStr).SetSelectable(true)
colTable.SetCell(row+1, 3, keyTypeCell) colTable.SetCell(row+1, 3, keyTypeCell)
// GUID - pad to 36 chars
guidStr := fmt.Sprintf("%-36s", column.GUID)
guidCell := tview.NewTableCell(guidStr).SetSelectable(true)
colTable.SetCell(row+1, 4, guidCell)
// Description // Description
descCell := tview.NewTableCell(column.Description).SetSelectable(true) descCell := tview.NewTableCell(column.Description).SetSelectable(true)
colTable.SetCell(row+1, 4, descCell) colTable.SetCell(row+1, 5, descCell)
} }
colTable.SetTitle(" Columns ").SetBorder(true).SetTitleAlign(tview.AlignLeft) colTable.SetTitle(" Columns ").SetBorder(true).SetTitleAlign(tview.AlignLeft)
@@ -490,6 +500,7 @@ func (se *SchemaEditor) showEditTableDialog(schemaIndex, tableIndex int) {
// Local variables to collect changes // Local variables to collect changes
newName := table.Name newName := table.Name
newDescription := table.Description newDescription := table.Description
newGUID := table.GUID
form.AddInputField("Table Name", table.Name, 40, nil, func(value string) { form.AddInputField("Table Name", table.Name, 40, nil, func(value string) {
newName = value newName = value
@@ -499,9 +510,14 @@ func (se *SchemaEditor) showEditTableDialog(schemaIndex, tableIndex int) {
newDescription = value newDescription = value
}) })
form.AddInputField("GUID", table.GUID, 40, nil, func(value string) {
newGUID = value
})
form.AddButton("Save", func() { form.AddButton("Save", func() {
// Apply changes using dataops // Apply changes using dataops
se.UpdateTable(schemaIndex, tableIndex, newName, newDescription) se.UpdateTable(schemaIndex, tableIndex, newName, newDescription)
se.db.Schemas[schemaIndex].Tables[tableIndex].GUID = newGUID
table := se.db.Schemas[schemaIndex].Tables[tableIndex] table := se.db.Schemas[schemaIndex].Tables[tableIndex]
se.pages.RemovePage("edit-table") se.pages.RemovePage("edit-table")