Add HasTable()

This commit is contained in:
Robert B Gordon 2014-08-29 00:28:54 -05:00
parent e6715ce175
commit 94aa843830
1 changed files with 6 additions and 0 deletions

View File

@ -346,6 +346,12 @@ func (s *DB) DropTableIfExists(value interface{}) *DB {
return s.clone().NewScope(value).dropTableIfExists().db return s.clone().NewScope(value).dropTableIfExists().db
} }
func (s *DB) HasTable(value interface{}) bool {
scope := s.clone().NewScope(value)
tableName := scope.TableName()
return scope.Dialect().HasTable(scope, tableName)
}
func (s *DB) AutoMigrate(values ...interface{}) *DB { func (s *DB) AutoMigrate(values ...interface{}) *DB {
db := s.clone() db := s.clone()
for _, value := range values { for _, value := range values {