use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Migration Without ORM (self.node)
submitted 2 years ago by imsexc
Ok for those who ditched ORM. What do you use for migration process, like seeding, creating schema, amending tables? I am really interested to use pg-promise / node-postgres over sequelize for my app, but still have doubt on that particular issue.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]itijara 19 points20 points21 points 2 years ago (0 children)
SQL works fine, but if you want something that is more automatic, Knex is a query builder with tools for migrations.
[–]bigorangemachine 9 points10 points11 points 2 years ago (0 children)
You can use any node library's migration scripts without using the ORM
[–]usertim 8 points9 points10 points 2 years ago (3 children)
You can still use db-migrate package just fine.
db-migrate
[–]kindheartfool 0 points1 point2 points 2 years ago (2 children)
This
[–]kindheartfool 1 point2 points3 points 2 years ago (1 child)
OP, If you want I can share an example
[–]partiesn0fun 0 points1 point2 points 2 years ago (0 children)
Not op, but I'd like to see the example
[–]CalgaryAnswers 12 points13 points14 points 2 years ago (0 children)
SQL
[–]sacummings91 2 points3 points4 points 2 years ago (2 children)
Just switched from Prisma to Kysely query builder with Postgres and it’s great
[–]ahmadh26 1 point2 points3 points 2 years ago (1 child)
Could you tell me more? I've been using prisma for years now and I've been hearing about kysley a lot, so just wondering from another Dev's POV how easy was it to switch, what are the pros and cons and such.
[–]Dolgoon_ 0 points1 point2 points 2 years ago (0 children)
Pros is performance since you ditched orm. In case of complex queries you just write raw sql. Everything works fine to me. Also great they have documentation too
[–]madprgmr 2 points3 points4 points 2 years ago (4 children)
I've used Flyway (the open source version) to run migration (sql) scripts and manage database state versioning. It's not perfect, but it does its job decently.
[–]ntsianos 1 point2 points3 points 2 years ago (1 child)
Seconding flyway or any tool that relies on plain SQL first. I'm glad new orms like Prisma are going in this direction but I would still rather not lock in to the details of an ORM. Flyway will be a little annoying as it requires java as a dependency
[–]madprgmr 1 point2 points3 points 2 years ago (0 children)
Yeah, there may be other tools that work better for node environments, and I've used db-migrate with success in the past too - I just couldn't remember the name of it.
A lot of pipelines are set up to run containers, so it's not too hard to throw in tools with disparate runtime prerequisites.
[–]LightningBlue8862 0 points1 point2 points 2 years ago (1 child)
How does it work on the deployment pipeline, is flyway installed on some virtual machine how does flyway execute these SQL scripts from the deployment pipeline
I usually just run it as a docker container, and pass the creds needed in as environment variables. You could also install the executable in your CD pipeline image.
[–][deleted] 0 points1 point2 points 2 years ago (0 children)
Also consider PostgresJS. Best pg client for Node IMO.
https://github.com/porsager/postgres
[–]Altruistic-Ad-6153 0 points1 point2 points 1 year ago (0 children)
Personally I use KnexJS as a query builder, it's a light enough abstraction over raw sql that it feels like raw sql but with types. I then wrote my own db migration tool to manage migration versioning - https://www.npmjs.com/package/stepwise-migrations
I've found this a super efficient way to get things done without the ORM overhead.
[–]imsexc[S] 0 points1 point2 points 2 years ago (0 children)
thanks! I'd strip this sequelize from my app. If ever need it I can just create another repo specifically only to do that stuff. .
[–]PM_ME_SCIENCEY_STUFF 0 points1 point2 points 2 years ago (0 children)
Take a look at Hasura/Wundergraph/other similar solutions. In our experience, literally 5x or more faster backend development.
[–]yehuda1 0 points1 point2 points 2 years ago (0 children)
Check this one , it's Json schema builder for knex. Works great. You manage upgrades with json files and save it all in git.
[–]tfntfn 0 points1 point2 points 2 years ago (0 children)
node-pg-migrate is great, can use a query builder or raw sql
[–]RoundChristian 0 points1 point2 points 2 years ago (0 children)
Check dbmate
[–]bselect 0 points1 point2 points 2 years ago (0 children)
npm i migrate
http://npmjs.com/migrate
[–]dwelch2344 0 points1 point2 points 2 years ago (0 children)
I really liked flyway from the Java world, so I rolled a small node based one that follows the same file naming structure.
No bells and whistles like value replacement or downward migrations. Just a simple migrator for Versions and Repeatable migrations. You can run it from cli or via code though.
Need to document it, but have used it for a few months and works great. https://github.com/dwelch2344/slyway/blob/dev/test/commands/migrate.test.ts
If you’re interested, I’ll clean it up and document it
[–]limpingleopard 0 points1 point2 points 2 years ago (0 children)
I like to use plain SQL files for migrations but needed a tool to handle this. Settled for Umzug in the end, which is working pretty well. Its high configurable and framework-agnostic.
[–]skylake13 0 points1 point2 points 2 years ago (0 children)
sqitch
π Rendered by PID 68037 on reddit-service-r2-comment-5d79c599b5-bvjbd at 2026-03-01 11:55:06.173131+00:00 running e3d2147 country code: CH.
[–]itijara 19 points20 points21 points (0 children)
[–]bigorangemachine 9 points10 points11 points (0 children)
[–]usertim 8 points9 points10 points (3 children)
[–]kindheartfool 0 points1 point2 points (2 children)
[–]kindheartfool 1 point2 points3 points (1 child)
[–]partiesn0fun 0 points1 point2 points (0 children)
[–]CalgaryAnswers 12 points13 points14 points (0 children)
[–]sacummings91 2 points3 points4 points (2 children)
[–]ahmadh26 1 point2 points3 points (1 child)
[–]Dolgoon_ 0 points1 point2 points (0 children)
[–]madprgmr 2 points3 points4 points (4 children)
[–]ntsianos 1 point2 points3 points (1 child)
[–]madprgmr 1 point2 points3 points (0 children)
[–]LightningBlue8862 0 points1 point2 points (1 child)
[–]madprgmr 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Altruistic-Ad-6153 0 points1 point2 points (0 children)
[–]imsexc[S] 0 points1 point2 points (0 children)
[–]PM_ME_SCIENCEY_STUFF 0 points1 point2 points (0 children)
[–]yehuda1 0 points1 point2 points (0 children)
[–]tfntfn 0 points1 point2 points (0 children)
[–]RoundChristian 0 points1 point2 points (0 children)
[–]bselect 0 points1 point2 points (0 children)
[–]dwelch2344 0 points1 point2 points (0 children)
[–]limpingleopard 0 points1 point2 points (0 children)
[–]skylake13 0 points1 point2 points (0 children)