You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--migrations to specify output directory for migrations #4720
With --schema we can now specify the file path of where the Prisma Schema is located, instead of the default ./prisma/schema.prisma. This has the unfortunate side effect, that migrations are also output next to that file - which might not be what you want.
We want to have a --migrations parameter that takes the path to a folder where all the migration related content is output. The default path for that parameter, if it is not supplied, thus is ./prisma/migrations.
Reacted by Nicklas 'Nick' Reincke, Vignesh T.V., Psycho Path, Sylvain, Cam C, EmberCM, Alexey Murz Korepov, Márcio Neto, Harshit Pant, pxDot and 31 more
Reacted by Emmanuel Meric de Bellefon, jaka-allermi, cheney-govolt and BenG
Super keen to see this feature come to life. I use Prisma Migrate across multiple stages, so the ability to specify a different migration folder for each Stage would be quite helpful.
Reacted by Gabriel Mesquita, Wilver Hidalgo, Rachide Ouattara, Facundo Merighi, Sijmen, Mohamed Elbalshy, Merlin, Bilal EL CHAMI, Alexis, cheney-govolt and 6 more
I have to somewhat disagree @rightroad, as solely relying on package.json to specify the migration output would exclude a certain number of use cases, like the one I just described around managing multiple stages from the same project. Adding an option to the CLI would allow to easily switch configs at runtime.
Yeah thank you for your reply @maoosi, having both options would be great! I think .env file also needs that change (or use .env on src folder) but that shouldn't be a big deal.
In our situation, we have a package in our monorepo for prisma. We have two databases, and each need their own prisma schema. Ideally we'd be able to commit migrations for both of them. As of now, we have to manually rename the migrations folder after running the migration, then commit that renamed folder, renaming it back to "migrations" when we want to run additional migrations. This would be unwieldy to do if we ran the migrations sequentially, but ideally we'd want to be able to run them concurrently, which wouldn't really work.
The prisma migrate command has a --schema flag that we're already using to point to our different schemas, ideally there'd be a corresponding flag to set the migrations folder.
As an alternative to the CLI flag, a block in the schema file would work, similar to how the generator client { } block has a output option. At least that would work for us, as our schemas and migrations are 1-to-1. Others may have setups that aren't 1-to-1.
Open to any and all feedback on how we could do things differently!
Reacted by Joël Galeran, Outsider, Emmanuel Meric de Bellefon, Ziyang Zeng, Matthew Bouchard, Edgar Guzman and Stephen Coloma
@benhickson Thank you for the detailed explanation!
I guess a workaround could be something like this, one folder per schema:
./src/db1/schema.prisma
./src/db2/schema.prisma
And then calling prisma commands with --schema="./src/db1/schema.prisma"
Migrate will then create a migrations directory next to each schema like
./src/db1/migrations/...
./src/db2/migrations/...
Is that a good enough workaround or customizing the name of the migrations directory would be better here?
Reacted by Ben H, Rachide Ouattara, Itor Isaias da Silva, Max Antony, guru-pi-xcels, hutch, Bryan Parker, Reza Ebrahimi, Valerii Petryniak, Alessandro Lodi and 4 more
I'm curious about "why" this feature is needed for you, so we can prioritize better.
Could you give example(s) where customizing the migrations folder (default is in ./prisma/migrations) is needed / better maybe?
Sometimes, I write different migration files depending on my current environment. For example, I would like to populate my local database with mock data, which I wouldn't want to do in other environments. For now, I have written a script to duplicate the schema file into different folders named after my environment and specify the --schema path in the CLI.
I'm not sure if this is a suitable example...
MySQL does not support multiSchema. Therefore, users create multiple schema.prisma files and also store the output in multiple directories (#16943, #2443). As a result, there is a need to manage migration files in multiple parts (since each database is separate in MySQL).
I am also look forward for this feature as we have a case to support both MySql and PostgreSql with same schema. Because depending on the client, we will have to switch DB.
Easy, clear, but I can't do it like this and I am a little disappointed.
And if there is one thing I don't like I do not like it is to be disappointed.
(Just joking, five points for Gryffondor if you have the reference)
Have a nice day !
Reacted by Éwerton Ferreira, David Carvalho and Kornel Kocsis
Activity
maoosi commentedon Sep 24, 2020
Super keen to see this feature come to life. I use Prisma Migrate across multiple stages, so the ability to specify a different migration folder for each Stage would be quite helpful.
zakthedev commentedon Sep 24, 2020
it would be better if the migrations output could be set via package.json as follows:
"prisma": {
"schema": "src/schema.prisma",
"migrateOutput" : "src/migrations/"
}
maoosi commentedon Sep 25, 2020
I have to somewhat disagree @rightroad, as solely relying on
package.jsonto specify the migration output would exclude a certain number of use cases, like the one I just described around managing multiple stages from the same project. Adding an option to the CLI would allow to easily switch configs at runtime.That being said, it would make sense to have both options available and align with what's already in place for the Prisma schema file location: https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema#prisma-schema-file-location
zakthedev commentedon Sep 27, 2020
Yeah thank you for your reply @maoosi, having both options would be great! I think .env file also needs that change (or use .env on src folder) but that shouldn't be a big deal.
benhickson commentedon Apr 27, 2021
Any updates on this? commenting to subscribe :)
Jolg42 commentedon May 5, 2021
Hi there! @benhickson & others
I'm curious about "why" this feature is needed for you, so we can prioritize better.
Could you give example(s) where customizing the migrations folder (default is in ./prisma/migrations) is needed / better maybe?
benhickson commentedon May 5, 2021
Hi @Jolg42 !
In our situation, we have a package in our monorepo for prisma. We have two databases, and each need their own prisma schema. Ideally we'd be able to commit migrations for both of them. As of now, we have to manually rename the migrations folder after running the migration, then commit that renamed folder, renaming it back to "migrations" when we want to run additional migrations. This would be unwieldy to do if we ran the migrations sequentially, but ideally we'd want to be able to run them concurrently, which wouldn't really work.
The prisma migrate command has a --schema flag that we're already using to point to our different schemas, ideally there'd be a corresponding flag to set the migrations folder.
As an alternative to the CLI flag, a block in the schema file would work, similar to how the
generator client { }block has aoutputoption. At least that would work for us, as our schemas and migrations are 1-to-1. Others may have setups that aren't 1-to-1.Open to any and all feedback on how we could do things differently!
Jolg42 commentedon May 5, 2021
@benhickson Thank you for the detailed explanation!
I guess a workaround could be something like this, one folder per schema:
And then calling prisma commands with
--schema="./src/db1/schema.prisma"Migrate will then create a migrations directory next to each schema like
Is that a good enough workaround or customizing the name of the migrations directory would be better here?
9 remaining items
carlosLMZarego commentedon Apr 18, 2023
A good example is when you run the migration in AWS lambda and you want to use the /temp folder for instance
w1am commentedon May 31, 2023
Sometimes, I write different migration files depending on my current environment. For example, I would like to populate my local database with mock data, which I wouldn't want to do in other environments. For now, I have written a script to duplicate the schema file into different folders named after my environment and specify the
--schemapath in the CLI.sacru2red commentedon Jun 1, 2023
I'm not sure if this is a suitable example...
MySQL does not support multiSchema. Therefore, users create multiple schema.prisma files and also store the output in multiple directories (#16943, #2443). As a result, there is a need to manage migration files in multiple parts (since each database is separate in MySQL).
pandeymangg commentedon Dec 9, 2024
any progress on this?
StiliyanKushev commentedon Feb 9, 2025
+1 Bump
Would love to see this feature come to life.
batchor commentedon Feb 25, 2025
@jkomyno Really hope this feature can land soon!
vitran96 commentedon Mar 6, 2025
I am also look forward for this feature as we have a case to support both MySql and PostgreSql with same schema. Because depending on the client, we will have to switch DB.
samislam commentedon May 18, 2025
It's been 5 years.
Frost-on-Web commentedon Jun 23, 2025
Actually I can't understand why this is not a basic feature.
I agree it is mostly for convenience and personal folder organization but what is not ?
My "wanted" Prisma folder :
My "wanted" package.json :
Easy, clear, but I can't do it like this and I am a little disappointed.
And if there is one thing I don't like I do not like it is to be disappointed.
(Just joking, five points for Gryffondor if you have the reference)
Have a nice day !
feat(config): add support for custom `path` for `migrations`, `views`…
FGoessler commentedon Jul 16, 2025
Am happy announce that with Prisma 6.12.0 you can now specify your migrations folder location via
prisma.config.ts. See the documentation here.We do not plan to add a CLI argument for this.
Am closing this issue now as the underlying problem should be solved with this. :)