Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: add database editing related api structures (#3064)

boojacke3813342dc91
diff --git a/api/database.go b/api/database.go
index 780af802cf..5cec835036 100644
--- a/api/database.go
+++ b/api/database.go
@@ -124,3 +124,68 @@ type DatabasePatch struct {
SyncStatus *SyncStatus
LastSuccessfulSyncTs *int64
}
+
+// DatabaseEdit is the API message for updating a database in UI editor.
+type DatabaseEdit struct {
+ DatabaseID int
+
+ CreateTableList []*CreateTableContext
+ AlterTableList []*AlterTableContext
+ DropTableList []*DropTableContext
+}
+
+// CreateTableContext is the edit database context to create a table.
+type CreateTableContext struct {
+ Name string
+ Type string
+ Engine string
+ Collation string
+ Comment string
+
+ AddColumnList []*AddColumnContext
+}
+
+// AlterTableContext is the edit database context to alter a table.
+type AlterTableContext struct {
+ TableID int
+
+ // ColumnNameList should be the final order of columns in UI editor and is used to confirm column positions.
+ ColumnNameList []string
+
+ AddColumnList []*AddColumnContext
+ AlterColumnList []*AlterColumnContext
+ DropColumnList []*DropColumnContext
+}
+
+// DropTableContext is the edit database context to drop a table.
+type DropTableContext struct {
+ TableID int
+}
+
+// AddColumnContext is the create/alter table context to add a column.
+type AddColumnContext struct {
+ Name string
+ Type string
+ CharacterSet string
+ Collation string
+ Comment string
+ Nullable bool
+ Default *string
+}
+
+// AlterColumnContext is the alter table context to alter a column.
+type AlterColumnContext struct {
+ Name string
+ Type *string
+ CharacterSet *string
+ Collation *string
+ Comment *string
+ Nullable *bool
+ Default *string
+ DropDefault *bool
+}
+
+// DropColumnContext is the alter table context to drop a column.
+type DropColumnContext struct {
+ Name string
+}