This commit is contained in:
shoopea 2019-07-08 11:49:03 +08:00
parent f110275228
commit 968035909d

9
sql.go
View File

@ -28,8 +28,13 @@ func initDB() {
err = rows.Scan(&name)
failOnError(err, "initDB : show tables listing")
_, err = tx.Exec("drop table " + name)
failOnError(err, "initDB : drop table "+name)
if ok, _ := regexp.MatchString(`^.*_v$`, name); !ok {
_, err = tx.Exec("drop view " + name)
failOnError(err, "initDB : drop view "+name)
} else {
_, err = tx.Exec("drop table " + name)
failOnError(err, "initDB : drop table "+name)
}
}
err = rows.Err()
failOnError(err, "initDB : show tables listing end")