Live data from Hacker News

Hassle-Free Database Migrations with Prisma Migrate

prisma.io

1–10 of 28 posts

Re: Hassle-Free Database Migrations with Prisma Migrate

#2
Database schema is not actually the most important thing i need to be a productive programmer.

What i need more is a smart ORM which gives me tool to calculate dependent fields based on other fields changes, then automatically store it on a field. Secondly, it should provide smart many2many relationship with smart caching techniques.

Those are features that prevents me to continue with RoR.

Re: Hassle-Free Database Migrations with Prisma Migrate

#3
post #2

Database schema is not actually the most important thing i need to be a productive programmer. What i need more is a smart ORM which gives me tool to calculate dependent fields based on other fields changes, then automatically store it on a field. Secondly, it should provide smart many2many relationship with smart caching techniques. Those are features that prevents me to continue with RoR.

Hi there,

I think Prisma might cover "smart many2many relationships". What exactly do you mean by smart caching techniques? Prisma is applying the dataloader pattern from GraphQL automatically under the hood, which we find to be a much easier thing to reason about compared to all the complexity of multi-tiered caching in Hibernate.

The dependent field requirement is super interesting, and something we will tackle in the future based on Change Data Capture. With Prisma you will be able to write a simple declarative data transformation, and the system will automatically keep the field up-to-date, even if the database is changed by another application, or manually by a user.

Hope that makes sense? :-)

Re: Hassle-Free Database Migrations with Prisma Migrate

#4
post #2

Database schema is not actually the most important thing i need to be a productive programmer. What i need more is a smart ORM which gives me tool to calculate dependent fields based on other fields changes, then automatically store it on a field. Secondly, it should provide smart many2many relationship with smart caching techniques. Those are features that prevents me to continue with RoR.

[deleted]

Re: Hassle-Free Database Migrations with Prisma Migrate

#5
Congrats on releasing this. I'm a big believer in declarative schema management. Migrate looks great, and I like how it allows autopilot, but that workflow step to inspect the generated migration AND to alter it, if it's incorrect or sub-optimal. This looks like a great tool.

We've been working on a similar tool that we've since donated to the CNCF and is now a Sandbox project (https://schemahero.io) that uses YAML to define a schema, and it's controlled by a Kubernetes operator. We realized that version control for the schema is great, and then you get GitOps integration so you can easily deploy and rollback. One of the compelling values of YAML for us was a) Kubernetes, so it's a default and b) Open Policy Agent can start to introduce a policies.

Prsima Migrate looks great. I think we'll see more tools like this as folks want to version control and implement policies and store metadata around their schemas to tightly couple the deployment to the app version.

Re: Hassle-Free Database Migrations with Prisma Migrate

#6
What I need from migrations is collaboration.

When I make a schema migration locally and push it to the repository, then 3 other PRs with their own migrations are being merged before mine, it is very likely that my local database will be in the wrong state.

Correct me if I'm wrong, but using an ORM (be it Django, Prisma, liquibase, ...) to handle your migrations will only generate the SQL queries for you, it won't handle "migration history merges" which is what you'll most likely need.

Your schema may be versioned in your repository, but not your data.

Therefore, you still need to coordinate your developers when database change are needed. And you'll most likely need to rm -rf your database locally and recreate it.

Unfortunately, that is not an easy problem to solve. Fortunately, this should not be a problem on production environments (where their history is more linear).

I'd be curious of any work on that subject.

Re: Hassle-Free Database Migrations with Prisma Migrate

#7
post #2

Database schema is not actually the most important thing i need to be a productive programmer. What i need more is a smart ORM which gives me tool to calculate dependent fields based on other fields changes, then automatically store it on a field. Secondly, it should provide smart many2many relationship with smart caching techniques. Those are features that prevents me to continue with RoR.

> What i need more is a smart ORM which gives me tool to calculate dependent fields based on other fields changes, then automatically store it on a field.

Is the ORM really the layer where you want those features? Because at the RDBMS layer you have views, materialized views, and triggers for that.

If you really want this at the ORM level, you can do it in RoR with e.g. model callbacks or custom attribute writers.

> Secondly, it should provide smart many2many relationship with smart caching techniques. Those are features that prevents me to continue with RoR.

RoR's many2many associations already do caching, though.

I don't see what you're lacking with RoR on either point.

Re: Hassle-Free Database Migrations with Prisma Migrate

#8
post #6

What I need from migrations is collaboration. When I make a schema migration locally and push it to the repository, then 3 other PRs with their own migrations are being merged before mine, it is very likely that my local database will be in the wrong state. Correct me if I'm wrong, but using an ORM (be it Django, Prisma, liquibase, ...) to handle your migrations will only generate the SQL queries for you, it won't ha…

The Prisma Migrate team is thinking about these issues. I'll let them elaborate when they wake up tomorrow :-)

We are taking inspiration from this great writeup on how Github has implemented a workflow that enable their developers to collaborate on Schema Migrations at scale: https://github.blog/2020-02-14-automating-mysql-schema-migra...

Re: Hassle-Free Database Migrations with Prisma Migrate

#9
post #6

What I need from migrations is collaboration. When I make a schema migration locally and push it to the repository, then 3 other PRs with their own migrations are being merged before mine, it is very likely that my local database will be in the wrong state. Correct me if I'm wrong, but using an ORM (be it Django, Prisma, liquibase, ...) to handle your migrations will only generate the SQL queries for you, it won't ha…

EF 6 had an interesting take on this problem. If two migrations had the same parent (aka we both branched and added a migration), whoever merged second would have to generate a "merge" migration to resolve the conflict. It wasn't the most elegant solution, or even a solution period, but it made the problem explicit. This happened because the full schema model was serialized and encoded into the migration journal table.

Re: Hassle-Free Database Migrations with Prisma Migrate

#10
post #5

Congrats on releasing this. I'm a big believer in declarative schema management. Migrate looks great, and I like how it allows autopilot, but that workflow step to inspect the generated migration AND to alter it, if it's incorrect or sub-optimal. This looks like a great tool. We've been working on a similar tool that we've since donated to the CNCF and is now a Sandbox project ( https://schemahero.io ) that uses YAML…

Thank you!

SchemaHero looks super interesting. I'll check with the team to make sure they take a look. Introducing a Kubernetes operator is pretty ambitious.

Post reply on HN