123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package modules
- import (
- "os"
- "golang-fave/consts"
- "golang-fave/engine/sqlw"
- "golang-fave/engine/wrapper"
- )
- func (this *Modules) RegisterAction_IndexCypressReset() *Action {
- return this.newAction(AInfo{
- WantDB: false,
- Mount: "index-cypress-reset",
- }, func(wrap *wrapper.Wrapper) {
- if !consts.ParamDebug {
- wrap.Write(`Access denied`)
- return
- }
- db, err := sqlw.Open("mysql", "root:root@tcp(localhost:3306)/fave")
- if err != nil {
- wrap.Write(err.Error())
- return
- }
- defer db.Close()
- err = db.Ping()
- if err != nil {
- wrap.Write(err.Error())
- return
- }
- os.Remove(wrap.DConfig + string(os.PathSeparator) + "mysql.json")
- os.Remove(wrap.DConfig + string(os.PathSeparator) + "config.json")
- _, _ = db.Exec(
- `DROP TABLE
- blog_cats,
- blog_cat_post_rel,
- blog_posts,
- pages,
- settings,
- shop_cat_product_rel,
- shop_cats,
- shop_currencies,
- shop_filter_product_values,
- shop_filters,
- shop_filters_values,
- shop_product_images,
- shop_products,
- users
- ;`,
- )
- wrap.Write(`OK`)
- })
- }
|