-
Notifications
You must be signed in to change notification settings - Fork 2
/
alter.go
51 lines (44 loc) · 867 Bytes
/
alter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package internal
import (
"fmt"
"strings"
)
type alterType int
const (
alterTypeNo alterType = 0
alterTypeCreate = 1
alterTypeDrop = 2
alterTypeAlter = 3
)
func (at alterType) String() string {
switch at {
case alterTypeNo:
return "not_change"
case alterTypeCreate:
return "create"
case alterTypeDrop:
return "drop"
case alterTypeAlter:
return "alter"
default:
return "unknow"
}
}
// TableAlterData 表的变更情况
type TableAlterData struct {
Table string
Type alterType
SQL string
SchemaDiff *SchemaDiff
}
func (ta *TableAlterData) String() string {
relationTables := ta.SchemaDiff.RelationTables()
fmtStr := `
-- Table : %s
-- Type : %s
-- RealtionTables : %s
-- SQL :
%s
`
return fmt.Sprintf(fmtStr, ta.Table, ta.Type, strings.Join(relationTables, ","), ta.SQL)
}