go-xorm / xorm

Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle, Moved to https://gitea.com/xorm/xorm
BSD 3-Clause "New" or "Revised" License
6.67k stars 754 forks source link

Mutilple indexs cross different columns #127

Closed 0x5487 closed 10 years ago

0x5487 commented 10 years ago

HI All,

I have a table with 4 columns. For example, a, b, c, d columns. I would like to create two unique indexs. One is called "unique1" based on a and b columns. Another is called "unique2" based on a and c columns. On the other hands, a columns has been used by two unique indexs. However, please correct me if I am wrong. It seems we can't create multiple indexs cross different columns at this moment. If the feature will be added that will be very useful.

Thank you Jason

lunny commented 10 years ago

I think this is you want.

type Table struct {
    A string `xorm:"unique(1) unique(2)"`
    B string `xorm:"unique(1)"`
    C string `xorm:"unique(2)"`
    D string
}
0x5487 commented 10 years ago

Hi Lunny,

Wow, awesome!! That is the feature I am looking for. Thanks for helping me. I appreciate your help.

Thanks, Jason