0

Yeah our website has so many problems because we customized our website excessively. So a few of records on table were created/removed while I don't aware of it.

I tried to add Time Stamp column on some tables under this issue. But some fatal errors came out after adding Time Stamp. Because I just create column without setting on either foreign key or primary key.

This is one of the error messages I faced.

An error occurred while saving this profile.SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (kbethos_wh.jet_profile_products, CONSTRAINT FK_JET_PROFILE_PRDS_PRD_ID_CAT_PRD_ENTT_ENTT_ID FOREIGN KEY (product_id) REFERENCES catalog_product_entity (entity_id) ON DELETE CASCADE), query was: INSERT INTO jet_profile_products (profile_id, product_id) VALUES (?, ?) File:/home/kbethos/public_html/wh/lib/Zend/Db/Statement/Pdo.php Line: 235

My question is without any problem, I want to add time stamp column because I would like to know when they are created by whom or some codes I haven't noticed.

I used this code to add time stamp column before

ALTER TABLE catalog_eav_attribute ADD lastUpdated TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;

1 Answer 1

0

You just need to turn off Foreign key checks off before you run your query and then re-enable after

SET FOREIGN_KEY_CHECKS = 0;

ALTER TABLE catalog_eav_attribute ADD lastUpdated TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;

SET FOREIGN_KEY_CHECKS = 1;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.