I would like a string-type field in a MySQL database which is case-insignificant and unique. I use the following model:
type user string {id} 64 json: "id" sql: "AUTO_INCREMENT" `email string 'json:" email "sql:" unique_index "` }
which makes email
unique, but
type user structure {id int64 `json:" id "sql: "AUTO_INCREMENT" `Email String` json:" email "sql:" Unique_index; COLLATION (utf8_general_ci) "`}
has no effect.
How can I set COLLATION to the field for the utf8_general_ci with GOM?
You can use the SQL tags in the area that you want to change, like this:
type user structure {gorm.Model name `sql:" type: VARCHAR (5) character set UTF8 COLLATE utf8_general_ci "`}
No comments:
Post a Comment