how to run migrations by code
See original GitHub issueI have a project with a main database, called general and inside it a table of companies, each company has a different database. My problem is the following, in this project I use the typeorm, but I am considering migrating to the prisma, the problem is that in the typeorm I can run the migrations inside the connection.
await connection.runMigrations({
transaction: 'all',
});
Is there any way to get it to run in the same way as typeorm here in prisma??
I can connect to another db with a custom url:
import { PrismaClient } from '@prisma/client'
const client1 = new PrismaClient({ datasources: { db: { url: 'postgres://localhost/db1' }} })
https://github.com/prisma/prisma/issues/2443#issuecomment-630679118
Issue Analytics
- State:
- Created a year ago
- Reactions:52
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Code-Based Migration in Entity Framework 6
To use code-based migrations, first execute the enable-migrations command in the Package Manager Console. Open the Package Manager Console from Tools ...
Read more >Code First Migrations - EF6 - Microsoft Learn
Generating & Running Migrations · Run the Update-Database command in Package Manager Console · Code First Migrations will compare the migrations ...
Read more >Running EFCore Migrations From Your Own Code
A beginner's guide to creating a simple console application that will allow you to run EF Core migrations from your own code.
Read more >Execute code first migration in code? - Stack Overflow
I think what I have to do is to use migrations for the base entities like Accounts and then run SQL scripts to...
Read more >Running & Scripting Migrations from Code - romiller.com
Running Migrations from Code. Running migrations is actually very simple. You need to instantiate an instance on the Configuration class that ...
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 FreeTop 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
Top GitHub Comments
@janpio I have a use case for you. We’re trying out https://github.com/testcontainers/testcontainers-node and we would like each of our test cases to bring up their own containers (postgres in this case), migrate the full database using Prisma programmatic API which will be fed with the temporal hosts/ports given from testcontainers (because it assigns different ones in each container) and then have all test cases run in parallel.
So programmatic access to Prisma will allow us to do that in just a cleaner way instead of running a script directly from the test case. Thanks, hope that makes sense
Here’s also older issue related to having programmatic access to the prisma migrator: https://github.com/prisma/prisma/issues/4703