From 94aa843830eb014e388aa8e713385445022cbf73 Mon Sep 17 00:00:00 2001 From: Robert B Gordon Date: Fri, 29 Aug 2014 00:28:54 -0500 Subject: [PATCH] Add HasTable() --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index 973c1b44..3ab03aaf 100644 --- a/main.go +++ b/main.go @@ -346,6 +346,12 @@ func (s *DB) DropTableIfExists(value interface{}) *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 { db := s.clone() for _, value := range values {