`prisma migrate dev --create-only` executed previously created migrations
See original GitHub issueBug description
prisma migrate dev --create-only
commits migrations previously created with --create-only
. This is not exactly a bug, but it’s unexpected behavior. I should be able to decide when to commit my migrations to the database.
How to reproduce
- Create a migration with
prisma migrate dev --create-only
- Change your schema
- Create another migration with
prisma migrate dev --create-only
- First migration is committed to the database.
Expected behavior
I expect the command --create-only
to only create a migration and do nothing else.
Prisma information
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["nativeTypes"]
binaryTargets = ["native", "rhel-openssl-1.0.x"]
}
Environment & setup
- OS: Catalina 10.15.7
- Database: Postgresql
- Node.js version: 12.22.1
Prisma Version
Environment variables loaded from .env
prisma : 3.1.1
@prisma/client : 3.1.1
Current platform : darwin
Query Engine (Node-API) : libquery-engine c22652b7e418506fab23052d569b85d3aec4883f (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli c22652b7e418506fab23052d569b85d3aec4883f (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core c22652b7e418506fab23052d569b85d3aec4883f (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt c22652b7e418506fab23052d569b85d3aec4883f (at node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : c22652b7e418506fab23052d569b85d3aec4883f
Studio : 0.423.0
Preview Features : nativeTypes
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Running prisma migrate dev --create-only actually applies ...
I just want it to blindly execute prior tested migration files if not already applied. I can use prisma migrate deploy for this....
Read more >Prisma Migrate in development and production
This page explains how to use Prisma Migrate commands in development and ... The --create-only command allows you to create a migration without...
Read more >Generating down migrations - Prisma
Create the up migration using migrate dev --create-only , so that it can be edited before it is applied to the database; Manually...
Read more >Prisma Migrate | Database, Schema, SQL Migration Tool
Generates a new migration from any changes you made to the Prisma schema before running migrate dev; Applies all unapplied migrations to the...
Read more >Prisma CLI Command Reference
prisma studio. Create migrations from your Prisma schema, apply them to the database, generate artifacts (e.g. Prisma Client). $ prisma migrate dev.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Mostly it’s the behavior I expect. For example, with rails/rake there were always two steps to migrating.
First you create the migration:
Then you migrate the data:
This wouldn’t be as important if prisma had a
rollback
command for migrations, but either way I expect this level of control for organizing db changes. For example, if I’m creating 3 tables, I’d prefer for them to each be in separate migrations (for naming and code standards), AND I need the option to dynamically update them before committing all 3. Currently, I’d have to create the migrations manually to do that.(While I’m at it, I’d also like to address this thought from https://github.com/prisma/prisma/issues/5553#issuecomment-873588154)
Yeah, it’s not as dangerous as losing data on production. But a big part of my full-stack workflow involves populating my dev database in the course of developing and trialling new front-end features. I build up with bunch of new data that’s directly relevant to the features I’m working on, covering the various extremes I want to handle. It’s not coming from a seed script or copied from production.
If I unexpectedly lose a column or a table, it’s not the end of the world. To be honest, the data is generally nonsense. But it’s my nonsense data! And hey, I was using that! I’d at least like a warning so I can decide if it’s worth making a quick backup copy, rather than spend half an hour generating brand new temporary nonsense.
Sure, sometimes even complete resets on dev are easier or inevitable. But when Prisma detects database drift, it suggests a reset and offers a choice… even though it’s just the dev database.