#Is there a way we can remove a field safely?

4 messages · Page 1 of 1 (latest)

placid dune
#

I'm removing the product_id from product option as our product will define the option for each category instead of by product. So we remove product_id and add category_id instead

For ex:
Clothing category will always have Size, Color...
Electronics > Phone: Screen Size, Storage...

But after removing and adding the category_id, I can't add product anymore because something is querying for product_id which is removed.

  query: 'SELECT "ProductOption"."id" AS "ProductOption_id", "ProductOption"."created_at" AS "ProductOption_created_at", "ProductOption"."updated_at" AS "ProductOption_updated_at", "ProductOption"."deleted_at" AS "ProductOption_deleted_at", "ProductOption"."title" AS "ProductOption_title", "ProductOption"."product_id" AS "ProductOption_product_id", "ProductOption"."metadata" AS "ProductOption_metadata" FROM "product_option" "ProductOption" WHERE ( "ProductOption"."product_id" IN ($1) ) AND ( "ProductOption"."deleted_at" IS NULL )',
  parameters: [ 'prod_01H1T1EESJCTA270ZFJ20FSXK1' ],
  driverError: error: column ProductOption.product_id does not exist
torpid raven
#

think it's much easier to leave everything as it is, and add options depending on the category via subscriber, or rewrite the creation route where you will check what category the product has and add options

torpid raven
#

or extend productService.create()

placid dune
#

I did that and encounter another problem