SGFGOV / medusa-strapi-repo

Monorepo for all Strapi components to sync with medusa
MIT License
70 stars 23 forks source link

After installing medusa strapi, i get an alter table product_tags_products_links error when i run npm run develop to start strapi #85

Open okechukwu0127 opened 5 days ago

okechukwu0127 commented 5 days ago

Describe the bug A clear and concise description of what the bug is. I have the medusa backend running 100% with no issues. I am also able to run the medusa frontend and they both communicate properly.

After installing strapi for medusa as specified in the documentation https://docs.medusajs.com/plugins/cms/strapi I get the following error when I try to run the command npm run develop inside the package/medusa-strapi folder

error: alter table "public"."product_tags_products_links" add constraint "product_tags_products_links_fk" foreign key ("product_tag_id") references "public"."product_tags" ("id") on delete CASCADE - there is no unique constraint matching given keys for referenced table "product_tags"

To Reproduce Steps to reproduce the behavior:

  1. cone https://github.com/SGFGOV/medusa-strapi-repo.git inside an already existing medusa backend
  2. Instal medusa-strapi, install dependencies by running yarn install
  3. After dependency installation is successfull, run the command npm run develop to start strapi server
  4. See error

Expected behavior Strapi Server should run successfully after running the npm run develop command from the medusa-strapi folder

Screenshots If applicable, add screenshots to help explain your problem.

image image image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

To resolve the issue, I added the id field to product_tags and executed the command but the error persisted

ALTER TABLE product_tags 
ADD CONSTRAINT unique_product_tag_id UNIQUE (id);

Kindly direct me on why I am getting this error

github-actions[bot] commented 5 days ago

Hi Thank you for highlighting this issue.

okechukwu0127 commented 4 days ago

Apparently the issue was due to the fact that I was pointing the strapi DB to the same DB use by my medusa backend. To resolve this, I provided a separate DB to Strapi and Medusa and Puff, the error when away