-
Notifications
You must be signed in to change notification settings - Fork 5
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
fixes orm migrations on start up #150
Conversation
Signed-off-by: Matt Raffel <mattr@kiva.org>
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.
Did you change something in the package.json? Just saw that 12K lines where removed from package-lock.json so wondering what's going on
Signed-off-by: Matt Raffel <mattr@kiva.org>
no. after running npm install, it changed. I assumed the previous package-lock file was wrong. I can revert if we wish. |
Signed-off-by: Matt Raffel <mattr@kiva.org>
Signed-off-by: Matt Raffel <mattr@kiva.org>
What's the problem this is fixing? As far as I can tell, the code works as intended Here's an example branch with a migration that works every way I can test it: https://github.com/kiva/aries-guardianship-agency/tree/sample-migration |
Tables are not getting created when: |
I know we talked about this elsewhere already, but this is the problem.
Which part is the fix for this? Is it the entities? |
We have already discussed all of this in slack. I am really confused why we are going over this again. If you would like, please work with Cam to see the problems. I am tired of being the middle man on this. |
This is why I brought it up in public, so that you don't have to be the middle man. I was hoping someone else, who is facing the issue, can explain to me what is going on now that it's in public. I'm definitely not trying to pull you in again. At the same time, I'm not very comfortable with this getting merged based on what I've heard about the problem, so I want my objection noted on the PR so others understand why it hasn't been merged yet. |
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.
This looks good to me 👍
FYI @jeffk-kiva it's nice when references to entities and migrations work both with typescript and with javascript as done here. It's good for developers to run build to transpile to js but it shouldn't be required (and ci runs build too so no worries there).
Note: the migration issue on my mac was I hadn't copied dummy.env to .env recently. I can confirm that this PR runs migrations on my machine even without a dist folder 👍
@jsaur The problem is if you have a reference to the same migration in both typescript and javascript, your code will fail, and it will do so in a fairly opaque way. This effectively forces you to use typescript locally.
Agree to disagree I guess, but there is absolutely no reason to skip the transpilation phase. Especially if you're working on code that alters core infrastructure, why would anyone be comfortable testing code that isn't the actual code that will be run in other environments? If it's because it's annoying to type one extra command, then just alter the All the "hard" problems we face using typescript are because it's actually javascript underneath the surface. When you decide to skip the transpilation step, you're saying you'd rather deal with those problems later in a remote environment, rather than sooner in a local environment. Do we suddenly not value "failing fast"? Also, you'll get errors that aren't actually errors. For example, I would agree with you if we were using ts-node in production (which apparently is mostly safe to do: TypeStrong/ts-node#104), but until then, I can't.
So the problem was not with migrations, but rather with environment variables. Why did we merge a "fix" when there's nothing to fix? |
It did fix an issue, Jeff. |
What issue did it fix? And to be clear, not being able to run migrations without transpiling your code is not an issue. |
I think my point is that philosophically we want things to work for developers when their developing locally using typescript and ts-node AND we also want things to work in javascript in production. For this particular case I didn't know that "if you have a reference to the same migration in both typescript and javascript, your code will fail, and it will do so in a fairly opaque way" - could you explain a bit more? If that's the case, then I agree, it's a good reason to say only do one or the other, and since we're using js in production we should do that. For most other things, eg Typeorm entities, it's really nice to have paths defined for both ts and js. |
While that may be nice in some cases, I don't really see the value. The only argument I can see for running ts-node is that some people may simply prefer it because they can add breakpoints more easily if they're debugging typescript. IDEs make that point moot, but I suppose we want to support the vim and emacs users of the world too. The argument that it's "easier" to run is also wrong, because all you have to do is change the npm What supporting both typescript and javascript really means is doubling the work, because to be sure everything actually works, it has to be tested and developed in typescript and in javascript. I'm sure that most developers are too lazy to do that, which means we have to rely on CI, which can be opaque and confusing when it fails. In other words, it makes it much harder to fail fast and visibly. There are many examples of this, one of which is the duplicate migration issue. Anyway, my point is that philosophically we want our code to work reliably, and choosing to run two different sets of code introduces a lot of complexity, which makes code not very reliable. What works for one developer will now not work for another developer. I get that there's often a tradeoff between making things as easy as possible for the developer and having reliable code. We want to be open and support a community, so we need to value making things easy for the developer. However, if the code is failing in ways that are invisible to some developers, that's not making things easy. And when it comes to code that manages the database, I think having reliable code is far more important than having "easy" code.
With the changes from this branch, if I run
I'm fine with this, I just don't understand what problem it solves, or why it's nice in this case. |
Ok so it sounds like there's a general issue and a specific issue: |
That sounds like a solid plan. And if it ends up being more of a pain than it's worth, then we can ignore it. CreateFoo came from the branch I made demonstrating a migration. I can walk you through how to reproduce it, but it might be easier on a call. There could be a bunch of reasons why you weren't able to reproduce it, cache invalidation being foremost amongst them, which is why I prefer not to develop in docker. But also, to be clear, I'm not saying this code breaks anything in CI or production, because the production Dockerfile doesn't copy anything from src and therefore only the |
Signed-off-by: Matt Raffel mattr@kiva.org