Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add foreign keys on all tables #3311

Merged
merged 23 commits into from
Dec 24, 2019

Conversation

djaiss
Copy link
Member

@djaiss djaiss commented Dec 17, 2019

This finishes the job of #2280 and will close #2280 too.

This adds foreign keys to all tables in Monica.

I also have written two new services:

  • ResetAccount
  • DestroyAccount

which makes the Settings controller a little bit lighter and cleaner. We don't need the old way of resetting and deleting accounts with the foreign keys everywhere.

@djaiss djaiss marked this pull request as ready for review December 18, 2019 22:10
@djaiss djaiss requested a review from asbiin December 18, 2019 22:10
@djaiss
Copy link
Member Author

djaiss commented Dec 19, 2019

Ready for review @asbiin

Copy link
Member

@asbiin asbiin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! Really.
See my comments ...

app/Http/Controllers/SettingsController.php Outdated Show resolved Hide resolved
@asbiin
Copy link
Member

asbiin commented Dec 20, 2019

I'm a little concerned about the performance here. The migration took ~6 sec on the build pipeline, on an empty database.

@djaiss
Copy link
Member Author

djaiss commented Dec 20, 2019

I'm a little concerned about the performance here. The migration took ~6 sec on the build pipeline, on an empty database.

It took 4 minutes on my machine with a database of the same size as the one in production.
The reason it takes so much time is because we have to look for every single entry in the DB in order to see if data really exists. This is why at the beginning of the file, I put the most frequent entries in an array instead of having to read from the DB again and again. This helped me reduced the time from 16 min to 4 min.

@djaiss
Copy link
Member Author

djaiss commented Dec 20, 2019

Things that remain to be done

  • Service to reset an account
  • Service to delete an account
  • Add foreign keys to contact table

@djaiss
Copy link
Member Author

djaiss commented Dec 20, 2019

Ready for a new review @asbiin

@asbiin
Copy link
Member

asbiin commented Dec 21, 2019

On account reset, could we consider delete the default data populated with $account->populateDefaultFields()?

Also, I think you could add a foreign key on avatar_photo_id?

@djaiss
Copy link
Member Author

djaiss commented Dec 22, 2019

On account reset, could we consider delete the default data populated with $account->populateDefaultFields()?

Why? We don't need to touch the default populated fields during the reset account process.

Also, I think you could add a foreign key on avatar_photo_id?

Excellent point!

@djaiss
Copy link
Member Author

djaiss commented Dec 23, 2019

@asbiin another review ;-)

@asbiin
Copy link
Member

asbiin commented Dec 24, 2019

OK for me, go for it!

@djaiss djaiss merged commit 70f2adb into master Dec 24, 2019
@djaiss djaiss deleted the 2019-12-16-add-foreign-keys-everywhere branch December 24, 2019 16:28
@github-actions
Copy link

github-actions bot commented Jan 9, 2021

This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants