Browse Source

Independent cypress reset action

Vova Tkach 5 years ago
parent
commit
e53de9ec69
1 changed files with 38 additions and 22 deletions
  1. 38 22
      modules/module_index_act_cypress.go

+ 38 - 22
modules/module_index_act_cypress.go

@@ -34,28 +34,44 @@ func (this *Modules) RegisterAction_IndexCypressReset() *Action {
 		os.Remove(wrap.DConfig + string(os.PathSeparator) + "config.json")
 		wrap.RemoveProductImageThumbnails("*", "*")
 
-		_, _ = db.Exec(
-			wrap.R.Context(),
-			`DROP TABLE
-				blog_cat_post_rel,
-				blog_cats,
-				blog_posts,
-				notify_mail,
-				pages,
-				settings,
-				shop_cat_product_rel,
-				shop_cats,
-				shop_currencies,
-				shop_filter_product_values,
-				shop_filters,
-				shop_filters_values,
-				shop_order_products,
-				shop_orders,
-				shop_product_images,
-				shop_products,
-				users
-			;`,
-		)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE blog_cat_post_rel DROP FOREIGN KEY FK_blog_cat_post_rel_post_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE blog_cat_post_rel DROP FOREIGN KEY FK_blog_cat_post_rel_category_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE blog_cats DROP FOREIGN KEY FK_blog_cats_user;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE blog_posts DROP FOREIGN KEY FK_blog_posts_user;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE blog_posts DROP FOREIGN KEY FK_blog_posts_category;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE pages DROP FOREIGN KEY FK_pages_user;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_cat_product_rel DROP FOREIGN KEY FK_shop_cat_product_rel_product_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_cat_product_rel DROP FOREIGN KEY FK_shop_cat_product_rel_category_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_cats DROP FOREIGN KEY FK_shop_cats_user;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_filter_product_values DROP FOREIGN KEY FK_shop_filter_product_values_product_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_filter_product_values DROP FOREIGN KEY FK_shop_filter_product_values_filter_value_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_filters_values DROP FOREIGN KEY FK_shop_filters_values_filter_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_orders DROP FOREIGN KEY FK_shop_orders_currency_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_order_products DROP FOREIGN KEY FK_shop_order_products_order_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_order_products DROP FOREIGN KEY FK_shop_order_products_product_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_product_images DROP FOREIGN KEY FK_shop_product_images_product_id;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_products DROP FOREIGN KEY FK_shop_products_user;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_products DROP FOREIGN KEY FK_shop_products_currency;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_products DROP FOREIGN KEY FK_shop_products_category;`)
+		_, _ = db.Exec(wrap.R.Context(), `ALTER TABLE shop_products DROP FOREIGN KEY FK_shop_products_parent_id;`)
+
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE blog_cat_post_rel;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE blog_cats;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE blog_posts;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE notify_mail;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE pages;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE settings;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE shop_cat_product_rel;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE shop_cats;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE shop_currencies;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE shop_filter_product_values;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE shop_filters_values;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE shop_filters;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE shop_order_products;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE shop_orders;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE shop_product_images;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE shop_products;`)
+		_, _ = db.Exec(wrap.R.Context(), `DROP TABLE users;`)
 
 		wrap.ResetCacheBlocks()