question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dev migration breaking with new release (4.4.0)

See original GitHub issue

Bug description

I have a Docker + Docker-compose setup for my Typescript + Fastify + Prisma project. Everything was working fine till yesterday when all of a sudden my docker container would hang at startup. It would happen at the step when running Prisma migrations (on migrate dev), soon realized that it was not creating new migrations. I had changed the schema.prisma file (modified and removed some columns). When I reverted the changes the docker container ran successfully and my server was up. To understand the issue I moved to a previous release(4.3.1) of Prisma and then made changes to schema.prism again, this time it worked as expected.

Dockerfile:

FROM node:lts As development

WORKDIR /app

RUN npm install -g pnpm
RUN npm install -g ts-node
COPY wait-for-it.sh .
RUN chmod +x wait-for-it.sh

COPY package*.json .
RUN npm i

COPY tsconfig.json .
COPY prisma .
COPY .env .

EXPOSE 3000 

docker-compose

version: "3.8"
networks:
  app-network:
    driver: bridge
services:
    server:
        build: .
        container_name: server
        ports:
            - 3000:3000
        links:
            - postgres
        depends_on:
            - postgres
        environment:
            DATABASE_URL: postgresql://postgres:topsecret@postgres:5432/luminai-local?schema=public&connect_timeout=600
        volumes:
            - ./src:/app/src
        networks:
            - app-network
        command: bash -c "./wait-for-it.sh postgres:5432 -- npx prisma generate && npx prisma migrate dev && npm run dev"

    postgres:
        image: postgres:14
        container_name: postgres
        hostname: postgres
        environment:
            POSTGRES_USER: postgres
            POSTGRES_PASSWORD: topsecret
            POSTGRES_DB: luminai-local
        restart: always
        networks:
            - app-network
    pgadmin:
        container_name: pgadmin4_container
        image: dpage/pgadmin4
        restart: always
        depends_on:
            - postgres
        environment:
            PGADMIN_DEFAULT_EMAIL: admin@admin.com
            PGADMIN_DEFAULT_PASSWORD: root
        ports:
            - 5050:80 # Access to pgadmin: localhost:5050
        networks:
            - app-network

package.json

  "dependencies": {
    "@prisma/client": "4.4.0",
     .....
  },
  "devDependencies": {
    "prisma": "4.4.0",
    .....
  }

Dropping the ^ fixed the issue for now.

How to reproduce

  1. Go to schema.prisma and change the columns
  2. run docker-compose on local machine
  3. docker container gets stuck
  4. No error per say, it just gets stuck:
wait-for-it.sh: waiting 15 seconds for postgres:5432
wait-for-it.sh: postgres:5432 is available after 5 seconds
Environment variables loaded from .env
Prisma schema loaded from schema.prisma

✔ Generated Prisma Client (4.4.0 | library) to ./node_modules/@prisma/client in 182ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

Environment variables loaded from .env
Prisma schema loaded from schema.prisma
Datasource "db": PostgreSQL database "luminai-local", schema "public" at "postgres:5432"

Applying migration `20220914231319_`

The following migration(s) have been applied:

migrations/
  └─ 20220914231319_/
    └─ migration.sql

Expected behavior

The expected behavior: it proceeds to print the line Your database is now in sync with your schema. after running migrations.

Prisma information

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
  binaryTargets = ["rhel-openssl-1.0.x", "native"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id          Int               @id @default(autoincrement())
  email       String            @unique
  role        Role              @default(Agent)
  createdAt   DateTime          @default(now())
  updatedAt   DateTime          @updatedAt
  firebaseId  String?           @unique
  active      Boolean           @default(true)
  team        Team              @relation(fields: [teamId], references: [id])
  teamId      Int
}

model Team {
  id          Int               @id @default(autoincrement())
  name        String            @unique
  user        User[]
  active      Boolean           @default(true)
  createdAt   DateTime          @default(now())
  updatedAt   DateTime          @updatedAt
}

enum Role {
    Agent
    Admin
}
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

export default prisma;

Environment & setup

  • OS: macOS
  • Database: PostgreSQL
  • Node.js version: v16.15.0

Prisma Version

4.4.0

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
iiAkucommented, Sep 29, 2022

We did not change the Prisma schema type and what it is translated to in the database in 4.4.0 @iiAku. We changed how values are modified before being inserted into the database. No changes for database schema and migrations, only for Prisma Client queries handling.

Yes definitely said it the wrong way. However was not saying the change was in the translation, saying that wether 4.3.1 or 4.4.0 you would get a precision = 3 as transaltion and if the client were doing an insertion with higher precision it will not work. Nevertheless you are right on your initial point, as long as the client is not involve you should not face any issue.

1reaction
janpiocommented, Sep 29, 2022

We did not change the Prisma schema type and what it is translated to in the database in 4.4.0 @iiAku. We changed how values are modified before being inserted into the database. No changes for database schema and migrations, only for Prisma Client queries handling.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade 4.3 to 4.4 MINOR version
This chapter describes how to upgrade Neo4j from an earlier MINOR version. It covers the following topics: Upgrading Neo4j 4.3 to 4.4 MINOR...
Read more >
Mule Runtime Engine 4.4.0 Release Notes
Visual Studio Code extension no longer breaks with binary input format in the test scenario inputs directory. W-11507190. Namespace is now added on...
Read more >
oVirt 4.4.0 Release Notes
The current release enables you to migrate a group of virtual machines (VMs) that are in positive enforcing affinity with each other. You...
Read more >
Migrate Guides - Strapi Developer Docs
Migrations are necessary when upgrades to Strapi include breaking changes. ... than 1 migration guide between your current version and the latest release, ......
Read more >
Upgrade to Prisma 4
Prisma 4 introduces a number of breaking changes when you upgrade from an ... done before running any npx prisma db push or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found