fix migrate migrationDidRun bug on postgres

This commit is contained in:
Lunny Xiao 2017-12-31 14:04:28 +08:00
parent 5185fdfa1b
commit abd3221470
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 1 additions and 3 deletions

View File

@ -194,9 +194,7 @@ func (m *Migrate) createMigrationTableIfNotExists() error {
}
func (m *Migrate) migrationDidRun(mig *Migration) bool {
row := m.db.DB().QueryRow(fmt.Sprintf("SELECT COUNT(*) FROM %s WHERE %s = ?", m.options.TableName, m.options.IDColumnName), mig.ID)
var count int
row.Scan(&count)
count, err := m.db.SQL(fmt.Sprintf("SELECT COUNT(*) FROM %s WHERE %s = ?", m.options.TableName, m.options.IDColumnName), mig.ID).Count()
return count > 0
}