https://www.prisma.io/ logo
Join Slack
Powered by
# prisma-migrate
  • q

    Quentin Laffont

    03/12/2022, 10:12 PM
    Hello hello 👋, I'm trying to create a migration script because my data need to be migrated but as I see on Github only SQL migrations are supported. Someone did have a solution to keep prisma migrate and execute JS / TS file ? Thanks ! ^^
    p
    • 2
    • 1
  • k

    Kevin Lanthier

    03/16/2022, 5:50 PM
    Hello prisma folks ! I show up today with an interesting migration question. I've added constraints to my database by creating a migration script manually (some fancy use cases) and for some reason, whenever I try to either
    migrate deploy
    or
    migrate dev
    , Prisma fails to do so and attempts to remove my constraints. It works when seeding from scratch, the constraint is picked-up and applied as part of the migration process, but past that whenever creating new migrations or just trying to apply a new one, I get into the same use case. from my understanding, since it's manually added, the schema is unaware of that constraint, but due to the use case of that constraint, I cannot add that to the schema itself. Thoughts ?
    d
    • 2
    • 1
  • a

    Adam

    04/01/2022, 8:14 PM
    We upgraded to
    v3.11.0
    from
    v2.27.0
    using Postgres and we just created our first migration file using
    npx prisma migrate dev --name test_migration_file --create-only
    and we are noticing a ton of changes that seem to drop all foreign key constraints and re-add them. Is this typical? Is this a cause of the version upgrade?
    j
    • 2
    • 5
  • c

    Chris

    04/05/2022, 4:30 PM
    Is there a way to make the migration warnings louder/actually error? Ie. to enforce no dropping of columns or risk of required fields.
    j
    j
    • 3
    • 4
  • t

    tornros

    04/14/2022, 6:22 AM
    Is it possible for the migrate deploy command to actual return the error when fails to migrate? Now we need to go into the db and look at the prisma_migrations table
    j
    • 2
    • 3
  • c

    Chris Gurba

    04/14/2022, 5:48 PM
    Do individual postgres migrations get wrapped in a transaction? I’m seeing behavior that makes me think they are, but this issue https://github.com/prisma/prisma/issues/8080 seems to suggest manually wrapping in BEGIN/COMMIT.
    • 1
    • 3
  • a

    alexwasik

    04/14/2022, 8:04 PM
    Here's an interesting one: I have created a migration to create a new table. I run the migration locally and everything works as expected (of course 🤦 ). I push everything to prod and run
    npx prisma migrate deploy
    and it completes the task. Of course i hit the endpoint locally, I get a response. I hit the prod endpoint and get
    Error: TypeError: Cannot read property 'findMany' of undefined
    a
    • 2
    • 16
  • k

    Kasir Barati

    04/21/2022, 12:55 PM
    Any body who does a
    npx prisma migrate --create-only
    ? I have to do it but I do not know how should I do it.
    ✅ 1
    • 1
    • 1
  • c

    Casey Chow

    04/21/2022, 4:34 PM
    I have a
    Makefile
    target specificallyl for this:
    Copy code
    migration: ## create a new schema migration
    	npx prisma migrate dev --create-only
    k
    • 2
    • 2
  • g

    Geo

    04/22/2022, 2:51 PM
    I'm trying to experiment with "native types mapping" and getting an error where the docs say it should work. Am I doing something wrong?
    Copy code
    Running generate... (Use --skip-generate to skip the generators)
    Error: Schema parsing
    error: Attribute not known: "@db.Text".
      -->  schema.prisma:54
       | 
    53 |   study_id        String?
    54 |   type            EmbedType @db.Text
    n
    • 2
    • 2
  • p

    Paul

    04/30/2022, 9:05 PM
    Hey guys, I have a question: For Security reasons, I have one database user that can do DDL commands called 'migrations' and other that can do DQL and DML called 'application' Let's think that I a have a production code with prisma and I have a pipeline to publish my api, the first step of my pipeline is to run the migrations step... My question is, how do you guys do with multiple database users? I'm thinking in have one .env.migration file with 'migration' database user and other .env file to run the app in production Is this a good way to handle this situation or is there another better way?
    ✅ 1
    n
    • 2
    • 2
  • j

    Jonathan Gotti

    05/04/2022, 7:44 PM
    Hi there, i'm pushing to production for first time and have some trouble when doing prisma migrate deploy as my database already contains tables (no conflict in table names) from another project. For now it's not possible to use a separate database in this environment. Is there anyway to make something like "prisma migrate deploy --force" ? Does anyone already have such situations and how did you do in such cases ? Thanks for your replies
    n
    • 2
    • 7
  • j

    Jacob Coker-Dukowitz

    05/06/2022, 6:07 PM
    Hi all, looking to confirm this question for deployment to production: From the docs:
    Prisma Migrate makes use of advisory locking when you run production commands like: prisma migrate deploy
    . Therefore, if I call
    prisma migrate deploy
    when my application is started, and there are multiple containers being deployed at the same time, other containers will sit on that advisory lock and not try to run migrations concurrently. Is that accurate?
    p
    • 2
    • 3
  • w

    Wade McDaniel

    05/10/2022, 6:10 PM
    I've got a dumb question: in a
    prisma migrate
    data migration in MySQL, how do I generate a "Prisma" ID - you know, one that looks like
    cl30ffuzq04558gfz8s0gi65y
    ? Is there a utility in MySQL, or maybe a stored-procedure I can create that generates compatible values to those Prisma generates?
    n
    • 2
    • 1
  • m

    Mathieu

    05/23/2022, 9:31 PM
    Hello, I am having an issue with the following schema:
    Copy code
    model User {
      id                 String               @id(map: "PK_cace4a159ff9f2512dd42373760") @default(dbgenerated("gen_random_uuid()")) @db.Uuid
      username           String               @unique(map: "UQ_78a916df40e02a9deb1c4b75edb") @db.VarChar
      email              String?              @unique(map: "UQ_e12875dfb3b1d92d7d7c5377e22") @db.VarChar
      password           String               @db.VarChar
    
      sheet Sheet[]
    
      @@index([username], map: "username-idx")
      @@map("user")
    }
    
    model Sheet {
      id          String     @id() @default(dbgenerated("gen_random_uuid()")) @db.Uuid
      author      User       @relation(fields: [authorId], references: [id])
      authorId    String     @db.Uuid
      name        String     @unique() @db.VarChar(512)
      slug        String     @unique() @db.VarChar(512)
    }
    When running
    npx prisma migrate dev --name sheets
    I get:
    Copy code
    Migration `20220523212222_sheets` failed to apply cleanly to the shadow database. 
    Error:
    db error: ERROR: foreign key constraint "Sheet_authorId_fkey" cannot be implemented
    DETAIL: Key columns "authorId" and "id" are of incompatible types: text and uuid.
    But I thought this line in the Sheet model was correct?
    Copy code
    authorId    String     @db.Uuid
    • 1
    • 1
  • s

    spohl

    05/25/2022, 8:22 AM
    Hi, i wonder if i can have a seed that updated a field if it is empty and fill it with a concatenation of 2 other fields in the same row. Maybe someone can give ma an advice?
    n
    • 2
    • 3
  • r

    Rahul Taing

    05/25/2022, 11:14 PM
    any recommendations on how to use prisma to backfill data? a typical scenario we have is that we add a column to a table. All the existing records need to be updated to add a value based on some logic. How can I use prisma to insert those values to the new column on existing records?
    b
    n
    • 3
    • 5
  • a

    Arkadiusz Dyczkowski

    05/26/2022, 9:07 AM
    Hey i have litle problem with foreignkeys in migration. Every time i run comand "npx prisma migrate dev --name" i get 4 keys removed and add those are allmost the same keys and i use them in same way in other tables but only those 2 causing problem
    Copy code
    ColumnName      Table1 @relation(fields: [ColumnNameId], references: [Id], name: "FirstParameterExactNameSpecifyInTable1")
      ColumnName2     Table1 @relation(fields: [ColumnName2Id], references: [Id], name: "SecondParameterExactNameSpecifyInTable1")
    Table1 Receiver lets say
    Copy code
    FirstParameterExactNameSpecifyInTable1 Organization[]                             @relation("FirstParameterExactNameSpecifyInTable1")
    SecondParameterExactNameSpecifyInTable1 Organization[]                             @relation("SecondParameterExactNameSpecifyInTable1")
    Meybe some of you could point me direction where could i find solution?
  • a

    Arkadiusz Dyczkowski

    05/26/2022, 9:59 AM
    ok i found the solution problem was in hand written migration which was nesesery to push data(infinity reference) Problem was that prisma didn't know what it shoud be onDelete and onUpdate and i had to specify + in 1 place had written that different option than in all others
  • r

    Rahul Taing

    05/27/2022, 10:13 PM
    trying to follow steps in down migration. after applying the down migration sql I try to mark the migration as rolled back but I get a
    cannot be rolled back because it is not in a failed state.
    error. What are the right steps to mark it as rolled back in _prisma_migration table._
  • r

    Roryl

    06/02/2022, 10:10 PM
    just got a quick question about the migration engine: how are out-of-order migrations handled? e.g. I create and apply a migration to my dev environment, then before committing it, a colleague creates and pushes a different migration which is then ran through our CI/CD pipeline. Now the production database will be missing my migration if I try to push it! Will this cause
    prisma migrate deploy
    to fail?
    n
    • 2
    • 3
  • s

    Stephane Le Dorze

    06/05/2022, 1:48 PM
    Hello all, I’m close to implement the workaround to speed up migrations here: https://github.com/prisma/prisma/issues/7933 before I do so, maybe there’s something I’m missing and there’s already a way to have them run fast.. Let me know I’m highly interested into that matter..
    n
    t
    • 3
    • 4
  • l

    Luan Rodrigues

    06/20/2022, 6:02 PM
    Hi, is there any feature to use migrations with data? I searched and didn't find anything focusing on this problem
    j
    • 2
    • 4
  • n

    Noctera

    06/27/2022, 2:33 PM
    Hi. Is there a way to run the migrations via the client? I'm currently refactoring my express Server with Sequelize ORM to Prisma. With Sequelize I was running the migrations on the Server startup, as the process got integrated in the code. But as far as I have seen with Prisma the only option to run migrations is by the CLI.
    f
    • 2
    • 1
  • p

    pmaneesh03

    07/05/2022, 10:14 AM
    I am facing an issue in prisma https://stackoverflow.com/questions/72828692/please-make-sure-your-database-server-is-running-at-localhost5432-prisma please help me to fix this issue
    a
    • 2
    • 1
  • o

    Oliver

    07/07/2022, 12:56 PM
    Hi everyone! I have a backend repo with Prisma in it, with a bunch of schema migrations inside a
    migrations/
    folder. I also have the backend running in production and it seems like somewhere along the line, the production Prisma DB migrations diverged from the one in the github repository. The production migrations seem to contain a migration that is not in the version controlled
    migrations/
    folder. It looks like the actual DB schemas are sync, but the migrations arent. Is there a way to sync them? Thanks
  • l

    Lee

    07/07/2022, 1:08 PM
    I have a project I'm working on and Supabase is the DB and I'm using Prisma Client with it. Everything in dev is functioning as it should. I'm getting my data back from my supabase DB. Now, when trying to deploy it on both Vercel and Netlify, everything is building fine with no errors but I am getting a 500-Failed to load data error when loading the pages consuming the data. I read the supabase docs on adding a shadow DB connection, so I did this and my migration and build was successful and still everything is functioning properly. I updated my ENV vars with the shadow DB and deployed. All deployed without errors except I'm still getting the 500-Failed to load data error. Any insight would be appreciated! Currently I have figured out that it works fine on the first migration, then it seems to change something in supabase because after further migrations, the data becomes unavailable. I saw a couple posts that talk about this. So everything works as expected in development, connected to Supabase...once I deploy it to lets say Vercel or Netlify, Data becomes unavailable. I've even added a shadow DB that Supabase and Vercel recommend. Has anyone had this issue before? Would appreciate any help I could get. Thanks!!!
    f
    • 2
    • 1
  • a

    Adam

    07/12/2022, 2:12 AM
    Is there a cleaner/more straightforward way to undo a bad migration in a dev/test environment? I had a migration that was committed to a dev branch deployed to a test system. The migration failed, so I simply deleted the
    migration.sql
    file, and deleted the record in
    _prisma_migrations
    and tried to re-deploy but it didn’t work. My flow now is to restore the db to the point before I deployed the broken migration, but it would be nice if there was a easier way to simply remove a migration and not do it before it goes to a higher level environment
    f
    • 2
    • 1
  • b

    Barnaby

    07/20/2022, 3:47 PM
    Hey, is there a way to run migrations without installing Node?
  • b

    Barnaby

    07/20/2022, 3:48 PM
    We use Prisma purely for the migration tools, but our stack is Golang. Currently we can't easily switch to using a scratch image (empty OS without any of the tools) because we need to install Node.js to execute
    prisma migrate deploy
    before the app starts up - is there a way to just grab the Rust binary directly and execute that?
    y
    j
    • 3
    • 6
1...56789Latest