From fdea835d53885ea9815c7dd19fae4040d8f955b9 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Sun, 18 Aug 2024 22:01:55 +0800 Subject: [PATCH] feat: added modify table --- core/entity/database.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/core/entity/database.go b/core/entity/database.go index 0dee0855..bd89b7ce 100644 --- a/core/entity/database.go +++ b/core/entity/database.go @@ -16,13 +16,14 @@ type DatabaseTable struct { } type DatabaseColumn struct { - Name string `json:"name"` - Type string `json:"type"` - Null bool `json:"null,omitempty"` - Key string `json:"key,omitempty"` - Default string `json:"default,omitempty"` - Extra string `json:"extra,omitempty"` - Children []DatabaseColumn `json:"children,omitempty"` + Name string `json:"name"` + Type string `json:"type"` + PrimaryKey bool `json:"primary_key,omitempty"` + Null bool `json:"null,omitempty"` + Key string `json:"key,omitempty"` + Default string `json:"default,omitempty"` + Extra string `json:"extra,omitempty"` + Children []DatabaseColumn `json:"children,omitempty"` } type DatabaseIndex struct { @@ -36,3 +37,11 @@ type DatabaseIndexColumn struct { Name string `json:"name"` Order int `json:"order"` } + +func (col *DatabaseIndexColumn) OrderString() string { + if col.Order < 0 { + return "DESC" + } else { + return "ASC" + } +}