File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ func parseDDL(strs ...string) (*ddl, error) {
162
162
for _ , column := range getAllColumns (matches [1 ]) {
163
163
for idx , c := range result .columns {
164
164
if c .NameValue .String == column {
165
- c .UniqueValue = sql.NullBool {Bool : true , Valid : true }
165
+ c .UniqueValue = sql.NullBool {Bool : strings . ToUpper ( strings . Fields ( str )[ 1 ]) == "UNIQUE" , Valid : true }
166
166
result .columns [idx ] = c
167
167
}
168
168
}
Original file line number Diff line number Diff line change @@ -79,6 +79,24 @@ func TestParseDDL(t *testing.T) {
79
79
},
80
80
},
81
81
},
82
+ {
83
+ "non-unique index" ,
84
+ []string {
85
+ "CREATE TABLE `test-c` (`field` integer NOT NULL)" ,
86
+ "CREATE INDEX `idx_uq` ON `test-b`(`field`) WHERE field = 0" ,
87
+ },
88
+ 1 ,
89
+ []migrator.ColumnType {
90
+ {
91
+ NameValue : sql.NullString {String : "field" , Valid : true },
92
+ DataTypeValue : sql.NullString {String : "integer" , Valid : true },
93
+ ColumnTypeValue : sql.NullString {String : "integer" , Valid : true },
94
+ PrimaryKeyValue : sql.NullBool {Bool : false , Valid : true },
95
+ UniqueValue : sql.NullBool {Bool : false , Valid : true },
96
+ NullableValue : sql.NullBool {Bool : false , Valid : true },
97
+ },
98
+ },
99
+ },
82
100
}
83
101
84
102
for _ , p := range params {
You can’t perform that action at this time.
0 commit comments