-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
SQL Migrations Not Working? #29
Comments
No need to read 001-initial.sql, the migration will do that for you. Moreover, the line Thus, the 4th line is effectively executed BEFORE the migration. This should work: const inMemoryDb = newDb();
await inMemoryDb.public.migrate();
const skills = inMemoryDb.public.many("select * from skills where name = 'Swift'");
console.log('skills', skills); You'll have to execute this from an async method, though. |
Got it working. What doesn't work is just calling The migration code also didn't report back when there was an I know that your existing test did specify a path While it works, their migration code is a complete hack job. I want to help you improve their code. So...I'm going to do a PR with:
Later on:
|
My New Tests@oguimbal I added a couple tests in the I don't see my new tests or migrate tests being run though after running them via pg-mem TestsAlso why pre-compile the tests? Can't you just run them on your tests folder, straight .ts. I never run my tests on compiled tests to js, it's unnecessary to setup all the precompiling of them with webpack. I honestly just wanna run tests on the .ts files using a simple mocha command, mocha runs fast by its very nature, you don't need to compile the tests physically like this, compile them on the fly using babel or something TSI also noticed that when I opened your project (I'm using WebStorm), TS is complaining about the migrate code. Is there any way I can turn that off? I mean you must have to be getting those errors too? The sqlite migrate code is a complete mess (I know you didn't write that and mostly ported it and tweaked it, but just saying) |
Tests Some kind of building (transpiling, actually) is necessary given that it's TS, so no, it is not possible to run mocha directly on ts files. When you do that on your side, I suppose that you're using ts-node or something equivalent, which is transpiling TS for you. That's also what does Webpack. Kind of an equivalent way to do the same thing. Moreover, the current setup of pg-mem tests is using webpack because it's way faster to code that way for me. That's a matter of choice. Ts compilation error I dont see this problem on my side ... |
yes I'm using I still have the problem whereas when I run your |
So I know you wrote a test to test that ported sqlite migration code, saw that test in one of your commits. But when I try this in my app, it's simply not working:
InMemoryDB.ts
the migrations folder is at the same level as InMemoryDB.ts and in that folder is:
001-initial.sql
- definitely adds a skills table seeded with some initial skills002-add-skills.sql
no idea here, thoughts?
The text was updated successfully, but these errors were encountered: