github.com/octohelm/storage@v0.0.0-20240516030302-1ac2cc1ea347/testdata/model/user_v2.go (about) 1 package model 2 3 import "github.com/octohelm/storage/pkg/sqlbuilder" 4 5 type UserV2 struct { 6 ID uint64 `db:"f_id,autoincrement"` 7 Nickname string `db:"f_nickname,size=255,default=''"` 8 Gender Gender `db:"f_gender,default='0'"` 9 Name string `db:"f_name,deprecated=f_real_name"` 10 RealName string `db:"f_real_name,size=255,default=''"` 11 // for modify testing 12 Age int8 `db:"f_age,default='0'"` 13 Username string `db:"f_username,deprecated"` 14 } 15 16 func (user *UserV2) TableName() string { 17 return "t_user" 18 } 19 20 func (user *UserV2) PrimaryKey() []string { 21 return []string{"ID"} 22 } 23 24 func (user *UserV2) Indexes() sqlbuilder.Indexes { 25 return sqlbuilder.Indexes{ 26 "i_nickname": {"Nickname"}, 27 } 28 } 29 30 func (user *UserV2) UniqueIndexes() sqlbuilder.Indexes { 31 return sqlbuilder.Indexes{ 32 "i_name": {"RealName"}, 33 "i_age": {"Age"}, 34 } 35 }