Merge pull request #919 from nkovacs/patch-1

fix mysql HasForeignKey
This commit is contained in:
Jinzhu 2016-03-23 07:13:27 +08:00
commit 7d5d171168
1 changed files with 1 additions and 1 deletions

View File

@ -99,7 +99,7 @@ func (s mysql) RemoveIndex(tableName string, indexName string) error {
func (s mysql) HasForeignKey(tableName string, foreignKeyName string) bool { func (s mysql) HasForeignKey(tableName string, foreignKeyName string) bool {
var count int var count int
s.db.QueryRow("SELECT count(*) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA=? AND TABLE_NAME=? AND CONSTRAINT_NAME=? AND CONSTRAINT_TYPE='FOREIGN KEY'", s.currentDatabase(), foreignKeyName).Scan(&count) s.db.QueryRow("SELECT count(*) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA=? AND TABLE_NAME=? AND CONSTRAINT_NAME=? AND CONSTRAINT_TYPE='FOREIGN KEY'", s.currentDatabase(), tableName, foreignKeyName).Scan(&count)
return count > 0 return count > 0
} }