Typeorm Migrations
HTML-код
- Опубликовано: 9 окт 2024
- Learn how to do migrations in Typeorm.
Beginner code: github.com/ben...
----
Video Suggestions:
Trello: trello.com/b/m...
Join the Trello board: trello.com/inv...
----
Follow Me Online Here:
GitHub: github.com/ben...
LinkedIn: / benawad
Instagram: / benawad97
Patreon: / benawad
----
Join the Discord: / discord
Twitter: / benawad
#benawad
TikTok: / benawad
----
Follow me online: voidpet.com/be...
#benawad
You saved my life. I was stuck with docker and typeorm migrations for a job opporunity test, and the combination of your videos just saved me. Thank you very much
I rarely get stuck or look for video tutorials, but I was able to make Migrations work with NestJS thanks to your video. You've earned my subscription
Awesome!
You just saved me a ton of stress Ben, thanks!
The way create to migration is same like Django. I thinks this is the best approch to use ORMs. Thanks for the video.
bring back this ben awad
Much more readable - thank you!
It's kinda baffling how despite the numerous of JS frameworks there are out there, there still isn't an ORM with a powerful and simple migration system as Django does
I mean, what about Prisma?
I don't understand how you initialize a database with the code first approach. I just can't find how to do this.
Thank you for the video. So technically if the "up" script fails the db connection fails and app crashes, right? Is there a way we can recover the db connection if "up" script fails?
Such a great feature. Thank you!
dude you saved me like 3 hours of digging, I've been stuck on why my migration commands would throw `function(exports, require, __filename).... Thanks for this tut Ben
How did you figure this out?
glad it was helpful, I can't remember how I figured that out
How do I make sure that typeorm never erases any of my data?
I lost about a day's work because of the synchronize feature and I'm scared of starting up my typeorm server again.
Realy Nice video Ben! Thanks! Going to use it for sure.
Thank you for nice lecture video, Ben ! But I'm having a trouble with ormconfig.json, which I divide its name property into 'dev' & 'test'. In this case, if I run the command(`npx ts-node ./node_modules/.bin/typeorm migration:generate -n Test`), it goes ERROR ( Can't find connection default ). So i've tried add NODE_ENV=dev, but it didn't work. Is there anything I can do to solve this ?
Sorry for excuse. There's an option for selecting a db's name by `-c` ! Solved it. Thank you.
No worries, nice find
This was a really helpful tutorial. I'm getting an Error when I try to do a migration:generate, though. Any ideas why I'd be getting 'Error: getaddrinfo ENOTFOUND database database:5432 at GetAddrInfoReqWrap.onlookup [as oncomplete]'? Thanks!
when using docker-compose I fix it with the second ormconfig.json file for cli connections where {host: 'localhost'}.
example
./docker-compose.yaml
....
db:
image: 'mysql:5.7.10'
ports:
- '3306:3306'
...
npm run typeorm migration:generate -- -n User -f ormconfig_2.json
can TypeORM generate all the SQL statements that will eventually create all tables based on the models?
typeorm migration:generate -n CreateDatabase
yes, just make sure when you run the generate command, your database has no tables or anything. Either move the `postgresdata` folder to somewhere else (if you want to preserve data), or just delete the `postgresdata` folder and restart postgres
Can I generate a migration "create table" files by passing some entities?
It's for how to alter table I am searching for how to create new tables.
Migrations do not work with .env file. Its a dealbreaker
Hey what utility do you use for command tips
fish shell
Great video... Although, I'm getting this error *Error during migration run {password authentication failed for user "", routine: 'auth_failed"} . Can you please help me?
did you set a password in your ormconfig.json
@@bawadyes I did, I'm still doing some research on a fix, thanks for your quick reply
I see it doesnt work for one to one relation?
I'm not sure
Hi Ben , have you used some kind of clustering in your node apps?
Something like this:
github.com/gottsohn/multi-core-node-js-example/blob/master/index.js
I haven't. Usually I replicate the docker container
Ben Awad I understand. I am using heroku, so no docket there. Thanks!
Oh I see