Merge pull request #959 from vibhavp/master

Fix postgres' HasForeignKey
This commit is contained in:
Jinzhu 2016-05-04 21:22:04 +08:00
commit bf413d67d3
1 changed files with 1 additions and 1 deletions

View File

@ -91,7 +91,7 @@ func (s postgres) HasIndex(tableName string, indexName string) bool {
func (s postgres) HasForeignKey(tableName string, foreignKeyName string) bool { func (s postgres) HasForeignKey(tableName string, foreignKeyName string) bool {
var count int var count int
s.db.QueryRow("SELECT count(con.conname) FROM pg_constraint con WHERE $1::regclass::oid = con.conrelid AND con.conname = $2 AND con.contype='f'", s.currentDatabase(), foreignKeyName).Scan(&count) s.db.QueryRow("SELECT count(con.conname) FROM pg_constraint con WHERE $1::regclass::oid = con.conrelid AND con.conname = $2 AND con.contype='f'", tableName, foreignKeyName).Scan(&count)
return count > 0 return count > 0
} }