Simpler (and correct) example for showing how to declare foreign keys.

Impact: Trivial.
This commit is contained in:
nicholasf 2015-04-22 12:54:19 -07:00
parent 3c2915a9df
commit a9aef2dd90
1 changed files with 1 additions and 1 deletions

View File

@ -1091,7 +1091,7 @@ type Product struct {
// 2nd param : destination table(id)
// 3rd param : ONDELETE
// 4th param : ONUPDATE
db.Model(&User{}).AddForeignKey("user_id", "destination_table(id)", "CASCADE", "RESTRICT")
db.Model(&User{}).AddForeignKey("role_id", "roles", "CASCADE", "RESTRICT")
// Add index
db.Model(&User{}).AddIndex("idx_user_name", "name")