How do you do UUID in Golangs Gorm?

后端 未结 3 2140
闹比i
闹比i 2021-02-19 15:24

I have the following model...

type User struct {
    ID        string  `sql:\"type:uuid;primary_key;default:uuid_generate_v4()\"`
    FirstName string `form:\"f         


        
3条回答
  •  粉色の甜心
    2021-02-19 15:43

    The error (pq: relation "users" does not exist) usually means that, the table users does not exists in the database. It has nothing to do with the relationship between two models.

    So basically, You first need to create the table in the database (Or auto migrate the database As per @Apin suggest). And try to re-run the same code.

提交回复
热议问题