# Friday, 17 December 2010

When you delete something in uCommerce it doesn’t really go away. Rather uCommerce employs soft deletes on various data objects, particularly in the catalog, to enable you to query historical data. e.g. for reporting purposes.

Some times however you’d like to clear test data from your catalogs and you need to get a little heavy handed to do it by going directly to the database and deleting the data.

Of course you have to observe the relations between existing data and delete in the proper order to avoid breaking constraints in the database. The uCommerce product is a rather complex collection of tables, which hold your custom properties, language variations, prices, relations to other catalog items such as other products and categories, which means that getting it right might be a little tricky.

image

Fortunately we already did the script for you and it goes a little something like this:

-- PLEASE NOTE: If you run this script against your uCommerce database all products and related data will be deleted.
-- There's no way to get it back unless you keep a database backup handy.
BEGIN TRANSACTION
DELETE FROM uCommerce_PriceGroupPrice
DELETE FROM uCommerce_ProductRelation
DELETE FROM uCommerce_CategoryProductRelation
DELETE FROM uCommerce_ProductProperty
DELETE FROM uCommerce_ProductDescriptionProperty
DELETE FROM uCommerce_ProductDescription
DELETE FROM uCommerce_Product
COMMIT TRANSACTION
Comments are closed.