-
Notifications
You must be signed in to change notification settings - Fork 44
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
Refactor version history (PART 1/2) #8041
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 quick comments
packages/commonwealth/server/controllers/server_threads_methods/update_thread.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any model associations... expecting comment with many comment versions and thread with many thread versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a thread which successfully created an equivalent version history entry but when I edited the same thread a new version history entry was not created.
Also, we should reorder the migrations so that the version history migration comes last.
There are associations but I put them in the models. This is because I could not get them to work in the associations.ts file. We should maybe think of going back to the original model (The one described in the sequelize docs) because using our custom associations implementation gets complicated when things break. Maybe we can discuss it during the friday platform meeting. |
Good catch, fixed.
Done |
packages/commonwealth/scripts/async-migrate-thread-version-history.ts
Outdated
Show resolved
Hide resolved
Ran it on frack, works correctly for both the thread and comment migrations (But takes a while) |
2 final questions:
|
It will not be necessary, since any new threads/comments would be marked with version_history_updated true. Although it wouldn't hurt to run it a 2nd time just to verify it doesn't update anything (Since it will mark all the old version histories version_history_updated as true after migration).
I hadn't checked. There was no noticeable slowdown on frick, but I was probably the only one using it while the script was running. I can add some sleep time, but it might be better to just run it plain. We can always abort the script if it slows down the site (And resume from where we stopped). |
This will be the first ticket of two in an expand/contract database migration pattern. This is the expand portion where we will create the new entries for version_history, but not delete the old ones until part 2.
Link to Issue
Closes: #7812
Description of Changes
Test Plan
select * from "ThreadVersionHistories";
has correct data)select * from "ThreadVersionHistories";
has correct data)select * from "CommentVersionHistories";
has correct data)select * from "CommentVersionHistories";
has correct data)Deployment Plan
heroku run bash -a [appname]
then in the packages/commonwealth directory runpnpm run async-migrate-thread-version-history
and thenpnpm run async-migrate-comment-version-history