diff --git a/association_test.go b/association_test.go index dfda46a5..fa018bdd 100644 --- a/association_test.go +++ b/association_test.go @@ -6,13 +6,8 @@ import ( ) func TestHasOneAndHasManyAssociation(t *testing.T) { - DB.DropTable(Category{}) - DB.DropTable(Post{}) - DB.DropTable(Comment{}) - - DB.CreateTable(Category{}) - DB.CreateTable(Post{}) - DB.CreateTable(Comment{}) + DB.DropTable(Category{}, Post{}, Comment{}) + DB.CreateTable(Category{}, Post{}, Comment{}) post := Post{ Title: "post 1", diff --git a/main.go b/main.go index 50aeb49c..657342e9 100644 --- a/main.go +++ b/main.go @@ -373,16 +373,28 @@ func (s *DB) RecordNotFound() bool { } // Migrations -func (s *DB) CreateTable(value interface{}) *DB { - return s.clone().NewScope(value).createTable().db +func (s *DB) CreateTable(values ...interface{}) *DB { + db := s.clone() + for _, value := range values { + db = db.NewScope(value).createTable().db + } + return db } -func (s *DB) DropTable(value interface{}) *DB { - return s.clone().NewScope(value).dropTable().db +func (s *DB) DropTable(values ...interface{}) *DB { + db := s.clone() + for _, value := range values { + db = db.NewScope(value).dropTable().db + } + return db } -func (s *DB) DropTableIfExists(value interface{}) *DB { - return s.clone().NewScope(value).dropTableIfExists().db +func (s *DB) DropTableIfExists(values ...interface{}) *DB { + db := s.clone() + for _, value := range values { + db = db.NewScope(value).dropTableIfExists().db + } + return db } func (s *DB) HasTable(value interface{}) bool {