-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
fix 1444 clean-up some old code #3792
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.
Looks good! I had some minor requests for changes, once those are in this would be good to merge :)
AND | ||
slug IN ( | ||
"stunting-vs-level-of-prosperity-over-time", | ||
"growth-of-income-and-trade" | ||
) |
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.
It's better not to hard-code these slugs. Removing the property is the right thing to do in any case and there might be new charts created in the mean time between looking these up and the PR being merged.
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.
Fair enough, I decided to keep it tight in case of breaking something unrelated, but the opposite is the case, I'll make that change
"growth-of-income-and-trade" | ||
) | ||
`) | ||
} |
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.
You correctly bump the schema version in this PR (nice!) - but then to make it consistent we should also bump all existing schema versions in the charts table as part of this migration (since the migration above makes sure that they actually adhere to the new schema)
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.
@danyx23 noted the positive feedback in the PR comment, I think this is a really good habit for devs in general, thanks :-)
Passed local re-run of |
@toni-sharpe thanks for the changes but there is an issue with it. When I said to "bump all existing schema versions in the charts table" I meant to write the sql query to set this as part of the migration. What you did was modify existing, old migrations. This is conceptually something that one should almost never do - migrations are a series of immutable up/down scripts to bring a database or other datastore from one know schema version to another. A database that the migrations are run against might be at the status of any point in between migrations and these migrations should always perform the same logic and have the same effect. If you modify migrations, this property is violated. It would also not lead to all the rows in the charts table having the correct, new schema version in the What we should do here is execute some sql like this: update charts
set config = json_set(config, '$.$schema', 'https://files.ourworldindata.org/schemas/grapher-schema.005.json'); |
@danyx23 right yes, apologies, my migration experience is a little rusty, it's been a while, let me make that change and I'll ping you when it's done. |
@danyx23 New commit is actually just your example, updates the |
@danyx23 I felt your suggested code was correct, re-building seems to work for me locally, I had missed the timestamp on the second migration, that's now added, the output for me: I have now I think fully fixed this I really hope, getting useed to TypeORM, had to move the migrations so they were last, as I think they have to be last when added, to keep it right. Local output
|
I also had a go at brevity in the PR description, it's a thing I've wated to improve and Lars has helped with a few pointers, so I applied those for practice. |
@danyx23 gentle reminder that this is still open. There is now a conflict in the schema, which I will try to resolve over the next day or so. I thought I had this ready, but now I'll take a look at the new problem and hopefully get it ready for merge. |
@danyx23 @larsyencken sorry to tag both, August is a barren month, this is ready I think, I'd quite like it merged before new migrations go in (I think the latest merged have to be the latest time-stamp). |
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.
Hey @toni-sharpe, sorry for the radio silence, I had a pretty busy time. The changes look good now!
We'll need to remove this property also from the schema definition in the ETL repository - could you send a PR to the ETL repo that removes the lines following https://github.com/owid/etl/blob/b07710d343a44e4c16091070ff0924e6e1d99b0f/schemas/dataset-schema.json#L1597 as well?
I would then merge both next week.
* instructions on [this PR](https://github.com/owid/owid-grapher/pull/3792\#pullrequestreview-2244102959) to keep things consistent were followed
The second commit can be reverted, it sets schemas all equal and incremented |
@toni-sharpe thanks! I left a comment over there. We have some changes coming in that will also touch the schema versions in a more complex way and it will be easier to merge your PR after those PRs. So I'll wait a few more days, but thanks for the cleanup! |
@danyx23 no problem, reverted on the other PR |
389a5ed
to
da28574
Compare
@danyx23 this is ready for a merge I think, conscious that new migrations mean I'll need to change my migration numbers to retain sync (I think). |
0899844
to
7e8d2d2
Compare
@danyx23 latext commit to keep migrations latest (I'm sure they have to be) |
* mistake made with schema update, a new migration should be added, not current ones renamed * the `down` portion reverts this value to schema 004
I can see from your comments that you wanted to wait before the merge with this, but, the waiting is creating updating, which are fiddly with migrations, I've rebased and force pushed, but I hit a conflict I had to manage manually, specifically, I removed this:
Also would this technically be schema 6? I'd suggest putting both as 5 just for the sake of simplicity, the sooner this is merged, the better IMO. Please let me know what's going on with the bigger picture, if you have the time, for the sake of my broader knowledge as well as this PR. |
Hi @toni-sharpe, sorry again that I wasn't more active, we were pretty busy trying to push a bigger project forward before a few key people go on vacation. We have merged a bunch of changes recently that are relevant for this PR. Key among them is that we introduced a Unfortunately this means that this PR has to change a bit now - the migration you had in place touched the The other thing I noticed is that the schema yaml had a change that moved the $defs section to the bottom. I guess something must have happened in your rebase because your diff now adds this back at the top but this would then lead to it existing both at the top and the bottom which would be invalid. Probably the easiest is to just remove your section at the top. I'm sorry that this PR was stalled for so long and that now non-trivial changes are required for it to be merged. If you like I'd be happy to take over and make the remaining adjustments and merge, but you are also welcome to make them of course if you are still up for it! |
One more tipp: you can run the command |
@danyx23 no problem, I'll try; Appreciate the situation, work is based on what the team prioritises, only reason I pushed herre was the DB migration angle. I'll run the tests, and I'll check the migration work, let's see where I get, |
* the chart config moved so now the focus is on a specific chart_configs table, not the charts table * didn't see the need to restrict by type, it would be a slower query, * did away with all the 005 schema stuff, assuming the new chart stuff covered that (my merge issues suggest this in fact)
@danyx23 I think that's it:
Then also gotr rid of the dupe from my rebase. Tests seemed to work, but I saw the Instead I flattened everything and re-run the app, was able to see migrations run, TMux run and to login at Migration output
|
Is there anything I can do to help with that? |
…ation in saveGrapher
I've removed lines 529 & 530 And added |
Hey @toni-sharpe! I'm doing a bit of cleanup on your PR before I merge. Thanks a lot for the work, I'll merge it today! |
@danyx23 I was interested in the fix and errors Linting done, not sure I'll not push |
@toni-sharpe yeah I didn't run the lint locally - I did this a little differently now. The point of this is that the function saveGrapher should be able to accept older schema versions (e.g. version 4 that still had this field). The typescript type definition claims that the newConfig value will match GrapherInterface which only models the latest version of the schema so this is not stricly speaking the correct type but at this point it's not worth the hassle of typing this fully correctly but also not better to declare newConfig as |
OK so there's a cross-over between the old and new ... the new won't, the old might, so only delete on the old
Thanks for the more detailed description. |
Fixes #1444
Charts
The chart, 1237, does not exist in the admin/test area anymore, ignored
Authors
I've taken Hannah and Max's responses plus subsequent label changes to mean all is well with removing.
Figured the lack of interest from them meant I could just move on
Migration
Seems to work ...
Output details collapsed
Of course, there's a command!
And that looks good too.