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

    Sang Kim

    12/28/2020, 5:48 AM
    Hello, I've been using prisma migrate(great funtionality!) for some time, but somehow when I typed the command just now, it doesn't work.
    npx prisma migrate save --experimental
    ✔️ 1
    j
    • 2
    • 4
  • h

    Hyo

    01/07/2021, 11:57 AM
    Hi. Thank you for the new [prisma migration](https://www.prisma.io/blog/prisma-migrate-preview-b5eno5g08d0b). I have a question on applying this to github workflow. We need to run
    prisma migrate dev
    and
    prisma migrate deploy
    to update our remote database and this should be done before merging the
    PR
    since the queries won’t work without it. The sourcecode will be deployed to production when merged to master. The problem is, when we run
    prisma migrate dev
    the prompt appears (Type in migration name) and we need to type in something to apply it. Should we run it before pushing the commits to
    branch
    that would be merged to
    master
    ? Currently, in our opensource project (https://github.com/dooboolab/hackatalk), we are doing
    prisma migrate dev
    and
    prisma migrate deploy
    locally when we updates
    schema.ts
    but I am wondering if this could be done over the air.
    j
    a
    • 3
    • 4
  • h

    Hyo

    01/11/2021, 2:22 AM
    What can we do if the
    primsa migrate dev
    failed?
    Copy code
    Error: The migration 20210111021729_item_style_none failed when applied to the shadow database.
    Fix the migration script and run yarn prisma migrate dev --preview-feature again.
    
    P3006
    Migration `20210111021729_item_style_none` failed to apply cleanly to a temporary database. 
    Error:
    Database error: Error accessing result set, column not found: itemStyle
       0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
                 at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:174
       1: sql_migration_connector::sql_database_migration_inferrer::validate_migrations
                 at migration-engine/connectors/sql-migration-connector/src/sql_database_migration_inferrer.rs:89
       2: migration_core::api::DiagnoseMigrationHistory
                 at migration-engine/core/src/api.rs:148
    error Command failed with exit code 1.
    info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
    j
    • 2
    • 5
  • d

    Daniell

    01/16/2021, 8:45 PM
    I am not sure if I should use migrate deploy or push
    RUN npx --no-install prisma migrate deploy --preview-feature
    for my Docker command 😅
    j
    • 2
    • 1
  • d

    Daniell

    01/16/2021, 8:45 PM
    It runs everytime I deploy my project
  • j

    John Peña

    01/19/2021, 4:10 PM
    anyone ever seen this error before running
    prisma migrate up --experimental
    (this is in version 2.12): ‘Error: Error in command input: Could not load migration from database.’
    j
    • 2
    • 4
  • b

    Barak Cohen

    01/21/2021, 4:01 PM
    hi, is there a way to run
    prisma db seed
    when prisma is in a custom folder? we're using nx to manage our monorepo and i can't find a flag to customize the path
    a
    • 2
    • 5
  • a

    Aleksandra Jovanović

    01/25/2021, 2:27 PM
    Hello folks 👋🏻 I have a question regarding the character set for generated migrations. I need to use
    utf8
    and I saw this issue where that behaviour was changed: https://github.com/prisma/prisma-engines/pull/889 Is there a way to specify it or do I have to first create the migration, modify it and then run it? Thanks 😊
    j
    t
    • 3
    • 4
  • a

    Aleksandra Jovanović

    01/26/2021, 11:01 AM
    Hello again! 👋🏻 I have one more question, I’m trying to introduce Prisma Migrate to an existing project. I’m using nativeTypes, and there is something strange happening every time I run
    prisma migrate dev --preview-feature
    (even when there’s no changes). In the .sql files there are a bunch of ALTER TABLE statements modifying every TINYINT to the same thing that they already are in the database. And it’s being generated every time, looks completely the same. This is an example:
    Copy code
    ALTER TABLE `category` MODIFY `active` TINYINT NOT NULL DEFAULT true;
    I was looking out for issues, and found this: https://github.com/prisma/prisma-engines/issues/1257. I’m not sure if that’s the same issue, if not I can open a new one 🙂 Thanks!
    t
    • 2
    • 2
  • p

    Pascal Sthamer

    01/28/2021, 9:20 AM
    When running
    prisma migrate dev --preview-feature
    with prisma 2.14.0, I get the following error:
    Copy code
    Error: A migration failed when applied to the shadow database:
    P3006
    Migration `20210128090300_init` failed to apply cleanly to a temporary database. 
    ERROR 42000 (1142): ALTER command denied to user
    I think the problem is that the database user does not have the required access to the shadow database. Only granting
    CREATE, DROP ON *.*
    like stated in the docs, seems to be not sufficient.
    ✔️ 1
    j
    • 2
    • 3
  • w

    William Minshew

    01/29/2021, 10:43 PM
    anyone know how to trouble shoot this? only thing I could find online so far was… dropping the database & rebuilding from scratch
    t
    • 2
    • 2
  • w

    William Minshew

    01/29/2021, 10:43 PM
    which feels subpar 😅
  • w

    William Minshew

    01/30/2021, 1:51 AM
    just went ahead & dropped & rebuilt
  • w

    William Minshew

    01/30/2021, 1:51 AM
    hopefully doesn’t happen again
    j
    • 2
    • 3
  • d

    Daniell

    01/31/2021, 2:42 PM
    Do you guys add native types to every field? If not, when do you not add them?
    d
    • 2
    • 3
  • ö

    Ömer Özdemir

    02/01/2021, 8:07 AM
    Hey guys, as I understand prisma migrate files working in change based way. I'm using github actions for cd, so everytime i want to make a change on database i have to add a one more migration file to the repo. is there a way to keep migration in a single file?
    j
    • 2
    • 6
  • d

    Daniell

    02/01/2021, 1:05 PM
    https://github.com/prisma/prisma/issues/5383 posted this issue a bit late so not sure if anything was done since I first mentioned it here, it actually seems to magically insert into the database properly when using enum values 🤔 but it won't work when comparing strings
  • d

    defrex

    02/01/2021, 5:26 PM
    Is
    prisma/migrations/migration_lock.toml
    intended to be commit to git, or does it just represent local state?
    j
    • 2
    • 1
  • z

    Zarazas

    02/02/2021, 12:23 AM
    I am using digital ocean’s database to benefit of it’s connection pooling. I am trying to use the
    prisma migrate reset --preview-feature -f
    command to run tests against my preview environment created by vercel. However I get
    Copy code
    Error: Database error: Error querying the database: db error: ERROR: must be owner of schema public
    On DigitalOcean the
    public
    schema is created by the role
    postgres
    which is AFAIK not accessible. Is there any solution to this problem?
    j
    • 2
    • 2
  • z

    Zarazas

    02/02/2021, 2:00 AM
    On a related note: Has anyone seen this? https://github.com/oguimbal/pg-mem would be awesome if it would work with prisma out of the box. Will try around with it this week
  • d

    Daniell

    02/02/2021, 10:23 AM
    How come sometimes when applying a migration it asks to create a new one?
    ✔️ 1
    j
    a
    • 3
    • 11
  • a

    Alberto Perdomo

    02/02/2021, 7:01 PM
    Hello! Sorry about the radio silence. We’ve been really busy since the start of the year. Here are a few updates of what we’ve been up to. https://github.com/prisma/prisma/issues/4531#issuecomment-771893085
    💯 1
  • a

    Alberto Perdomo

    02/02/2021, 7:03 PM
    Update: 2.15.0 release In 2.15.0 we added support for native types in Prisma Migrate via the
    nativeTypes
    preview feature. Using the native type syntax for PSL, Prisma Migrate will generate the corresponding DDL statements in the migrations. We also added support for seeding. You can find the guide here and the reference docs here. Feedback for the seeding functionality can be shared here. Prisma Migrate will automatically trigger seeding when the database is reset. More info in the release notes for 2.15.0.
  • a

    Alberto Perdomo

    02/02/2021, 7:06 PM
    Update: 2.16.0 release As you may have noticed most of our team effort in the last two weeks has been spent on native types and improving its compatibility with Prisma Migrate. We’ve now added
    Unsupported(String)
    and
    dbgenerated(String)
    , which makes it possible to use Prisma Migrate to manage columns of types that are not yet supported by Prisma. Example:
    Copy code
    generator client {
      provider        = "prisma-client-js"
      previewFeatures = ["nativeTypes"]
    }
    
    datasource db {
      provider = "mysql"
      url      = env("DATABASE_URL")
    }
    
    model User {
      id    Int                            @id @default(autoincrement())
      email String                         @unique
      name  String?
      bio   Unsupported("multilinestring") @unique @default(dbgenerated("''"))
    }
    Prisma Migrate generates the following migration:
    Copy code
    CREATE TABLE `User` (
      `id` INTEGER NOT NULL AUTO_INCREMENT,
      `email` VARCHAR(191) NOT NULL,
      `name` VARCHAR(191),
      `multilinestringField` multilinestring NOT NULL DEFAULT '',
    
      UNIQUE INDEX `User.email_unique`(`email`),
      UNIQUE INDEX `User.bio_unique`(`bio`),
      PRIMARY KEY (`id`)
    );
    dbgenerated(String)
    can also be used with supported native types. Here is an example of how to leverage this to use database-generated UUIDs as default for a UUID column:
    Copy code
    model User {
      id   String  @id @db.Uuid @default(dbgenerated("gen_random_uuid()"))
      name String?
    }
    Prisma Migrate generates the following migration:
    Copy code
    CREATE TABLE "User" (
        "id" UUID NOT NULL DEFAULT gen_random_uuid(),
        "name" TEXT,
    
        PRIMARY KEY ("id")
    );
    There is a new option
    --skip-seeding
    for
    prisma migrate reset
    and
    prisma migrate dev
    . More info in the release notes for 2.16.0.
  • a

    Alberto Perdomo

    02/03/2021, 1:05 PM
    <!here> We are looking for a last round of feedback on nativeTypes (supported in Prisma Migrate since 2.15.0). Please share your feedback here or via GitHub. Also see my relevant updates about 2.15.0 and 2.16.0 above ☝️
  • b

    Bart W

    02/07/2021, 12:04 AM
    Is there a way to have prisma show or generate a migration without executing it?
    j
    • 2
    • 2
  • c

    chrisdhanaraj

    02/11/2021, 4:58 AM
    So ah - I think I might have a really dumb question but dropping it in here anyways 😄 I've inherited a Prisma project from another dev and it was on the older prisma betas - no real seed step here, so what I did was to do a
    pg_dump / pg_restore
    to get a set of data to work with (also, I like developing with a clone of real data). However, when running
    prisma migrate
    it's always going to reset my db from scratch - is there a good workflow to • Seed my local database with production data • Update my database with some new model (i.e., add a column), without blowing it all up?
    j
    a
    • 3
    • 4
  • t

    tom

    02/16/2021, 3:10 PM
    Hi, migrate users! There are some potentially breaking changes in the new release, especially if you are using column types that are not the migrate defaults . Also note that the Float <-> Decimal types have been remapped on postgres and mysql. For the whole story, you can read the release notes: https://github.com/prisma/prisma/releases/tag/2.17.0 All these changes are a consequence of the native types preview feature becoming stable: you can express a much richer set of types in your prisma schema now. It's also an important milestone towards the stabilization of migrate. Please feel free to ask any questions and send feedback in this thread or in GitHub issues :)
    👍 3
  • b

    Billy Ohgren

    02/16/2021, 6:16 PM
    Hi! I’m currently moving away from self hosted Jenkins (on aws, inside our VPC) to GitHub actions (outside of our VPC). Our database server, RDS, is locked down to only be accessible from our VPC on AWS and it would be nice to keep it this way. Everything works great with GitHub actions except for the step where we need to call Prisma migrate. Does anyone have a similar setup? Can the prisma migrate step happen when the container starts on ECS somehow? I would prefer to do it in the deploy process and preferably without hosting an SSH tunnel on AWS
    j
    t
    j
    • 4
    • 10
  • m

    Mike Cavaliere

    02/17/2021, 2:12 PM
    Hey all! I added the following field to my schema, and am unable to migrate since the existing tables don't have a default value. Is there a way to update existing data with Prisma? New field:
    uuid        String             @default(uuid())
    Postgres error:
    Error: Database error: Null constraint failed: (uuid)
    t
    • 2
    • 11
12345...9Latest