Add DropTableIfExists.
This commit is contained in:
parent
ffab2d3901
commit
5ad9306146
4
main.go
4
main.go
@ -340,6 +340,10 @@ func (s *DB) DropTable(value interface{}) *DB {
|
|||||||
return s.clone().NewScope(value).dropTable().db
|
return s.clone().NewScope(value).dropTable().db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DB) DropTableIfExists(value interface{}) *DB {
|
||||||
|
return s.clone().NewScope(value).dropTableIfExists().db
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DB) AutoMigrate(value interface{}) *DB {
|
func (s *DB) AutoMigrate(value interface{}) *DB {
|
||||||
return s.clone().NewScope(value).autoMigrate().db
|
return s.clone().NewScope(value).autoMigrate().db
|
||||||
}
|
}
|
||||||
|
@ -495,6 +495,11 @@ func (scope *Scope) dropTable() *Scope {
|
|||||||
return scope
|
return scope
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (scope *Scope) dropTableIfExists() *Scope {
|
||||||
|
scope.Raw(fmt.Sprintf("DROP TABLE IF EXISTS %v", scope.QuotedTableName())).Exec()
|
||||||
|
return scope
|
||||||
|
}
|
||||||
|
|
||||||
func (scope *Scope) modifyColumn(column string, typ string) {
|
func (scope *Scope) modifyColumn(column string, typ string) {
|
||||||
scope.Raw(fmt.Sprintf("ALTER TABLE %v MODIFY %v %v", scope.QuotedTableName(), scope.Quote(column), typ)).Exec()
|
scope.Raw(fmt.Sprintf("ALTER TABLE %v MODIFY %v %v", scope.QuotedTableName(), scope.Quote(column), typ)).Exec()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user