Skip to content
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

@slonik/migrator is not compatible with slonik 30+ #118

Open
levonka opened this issue May 27, 2023 · 9 comments
Open

@slonik/migrator is not compatible with slonik 30+ #118

levonka opened this issue May 27, 2023 · 9 comments

Comments

@levonka
Copy link

levonka commented May 27, 2023

@slonik/migrator is not compatible with slonik 30+, so you cannot create a migration.

To reproduce just delete node_modules folder and try to npm install packages.

@Sairyss
Copy link
Owner

Sairyss commented May 29, 2023

You have to force it npm install --force and it should work, this is a workaround for now until @slonik/migrator updates the package (or until I replace it for something else).

@levonka
Copy link
Author

levonka commented May 29, 2023

@Sairyss what do you think of typeorm? Maybe I can help you switch from slonik to it

@Sairyss
Copy link
Owner

Sairyss commented May 29, 2023

This project was using TypeOrm before slonik.
ORMs are generally not very flexible and performant for big applications so I prefer using raw queries instead.
This is discussed briefly at the end of Persistence models section.

@levonka
Copy link
Author

levonka commented May 29, 2023

@Sairyss Indeed, thank you.
Do you know any worthy alternatives to slonik?

@Sairyss
Copy link
Owner

Sairyss commented May 30, 2023

Not really. If you want raw queries you either use pg, which is very barebones, or Slonik that offers some nice extra features on top.
Alternatively you can use a query builder, there are couple of options here:

  • knex is a standard for some time now
  • kysely is an emerging star nowadays

But I'm not a big fan of query builders tbh so I prefer raw queries.

Although if your project is not very complex, using an ORM instead is totally fine. You could even use both options and combine power of ORM for types, migrations, easy inserts, simple queries, etc. and use raw queries when you need performance/flexibility. All depends on the project.

@levonka
Copy link
Author

levonka commented May 31, 2023

Thanks for the answer

@zacharyweidenbach
Copy link

I also prefer slonik to ORMs. Due to the poor state of affairs with slonik migration libraries, I have used knex strictly for migrations while using slonik for all application queries, and this has worked well. It might create some ambiguity for new devs because knex implies that the application code makes use of it as an ORM. Adding something to the README seems an easy enough way to resolve this confusion, though. Maybe something to consider for this repository since the need to use --force for the npm install is not obvious and hurts what is otherwise a very polished setup experience.

@marcoturi
Copy link

First of all, thank you @Sairyss for the immense work you have done in this repo. I started reading the issue related to the one discussed here in the @slonik/migrator repo mmkal/slonik-tools#417

I have never used slonik, but from what I read there are two aspects that stand out although I really like it and agree that for a large project a raw query approach could be preferable:

  • The project appears to be managed by only one person.
  • The project had gone several major changes in the same year (and thats why slonik-tools is not updated yet) .

Don't you think it would be problematic in a large and complex project, in the long term, relying for the DB layer, on a library managed by a single person and which often introduces major changes based mostly on the opinion of himself ? Would you make the same choice and pick slonik for a new project even today?

@Sairyss
Copy link
Owner

Sairyss commented Apr 2, 2024

@marcoturi Yeah, breaking changes is definitely an issue. Though slonik is a pretty minimal wrapper, you could create your own or fork it. In one of my projects, way before I found out about slonik, I created my own lib similar to slonik (though somewhat simplified). It took me about a couple of days and still works fine to this day.

If I had to choose what to use today, I would probably fork slonik and remove all unnecessary bloat from it, adapt it to my needs, and use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants