Golang Drop Table PostgreSQL MySQL
API
To see the full list of supported methods, see DropTableQuery.
db.NewDropTable().
Model(&strct).
Table("table1"). // quotes table names
TableExpr("table1"). // arbitrary unsafe expression
ModelTableExpr("table1"). // overrides model table name
IfExists().
Cascade().
Restrict().
Exec(ctx)
Example
To drop PostgreSQL/MySQL table:
_, err := db.NewDropTable().Model((*Book)(nil)).IfExists().Exec(ctx)
if err != nil {
panic(err)
}