yii2-usuario icon indicating copy to clipboard operation
yii2-usuario copied to clipboard

FK has no action for ON UPDATE

Open bscheshirwork opened this issue 7 years ago • 2 comments
trafficstars

What steps will reproduce the problem?

I can't change id of user becouse FK is no action for ON UPDATE

What a reason for this behavior?

for profile, social_account, token

What is the expected result?

ALTER TABLE profile DROP FOREIGN KEY fk_profile_user;
ALTER TABLE profile
ADD CONSTRAINT fk_profile_user
FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE ON UPDATE CASCADE;

What do you get instead?

FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE;

https://github.com/2amigos/yii2-usuario/blob/c0afdd55c948f0aac1c8ef06e2136003485e9585/src/User/Migration/m000000_000002_create_profile_table.php#L39-L41

docs https://github.com/yiisoft/yii2/blob/558cd482d8a0525fceec8646ea20ccc9b7c3fdf4/framework/db/Migration.php#L453-L464

bscheshirwork avatar Oct 16 '18 14:10 bscheshirwork

Some people do want RESTRICT vs CASCADE as modifying the ID of the user is not very common. How can we implement both worlds?

tonydspaniard avatar Jun 29 '19 05:06 tonydspaniard

Some people do want RESTRICT vs CASCADE as modifying the ID

In module's internal logic? We must put both of model in synchronized state

bscheshirwork avatar Jun 29 '19 08:06 bscheshirwork