Prisma introspect during "migrate" upgrade process re-formatted and schema and removed comments/structure
See original GitHub issueBug description
We’re doing a migration and found the tooling updated so I started going through this: https://www.prisma.io/docs/guides/prisma-guides/prisma-migrate-guides/add-prisma-migrate-to-a-project
When I ran prisma introspect
my schema was re-formatted and all the fields moved around and comments were removed:
model Server {
- id String @id @default(uuid())
-
- // essential data (short names to save data!)
- ip String @unique
- hn String
- pc Int
- pm Int
- gm String
- la String
- pa Boolean
- vn String
- ru Rule[]
-
- // domain name for de-duplication purposes
- domain String?
-
- // rich data (entered by server owners via the web UI)
+ id String @id @default(uuid())
+ ip String @unique
+ hn String
+ pc Int
+ pm Int
+ gm String
+ la String
+ pa Boolean
+ vn String
+ domain String?
description String?
banner String?
-
- // user who owns this server
- User User? @relation(fields: [userId], references: [id])
- userId String?
-
- active Boolean
- updatedAt DateTime @updatedAt
+ userId String?
+ active Boolean
+ updatedAt DateTime @updatedAt
+ User User? @relation(fields: [userId], references: [id])
+ ru Rule[]
}
I’m not sure if there were any necessary changes here that are required by the upgrade process.
How to reproduce
I’m guessing you just do a migrate on a slightly outdated prisma project. You can repro it with our open source project: https://github.com/openmultiplayer/web
Expected behavior
I didn’t expect the introspect command to actually edit the schema, and if it did, I would have assumed comments and structure would not be touched.
Prisma information
https://github.com/openmultiplayer/web
Environment & setup
- OS: Windows
- Database: PostgreSQL
- Node.js version: v12.18.3
- Prisma version:
web on master [✘!] via 🐹 v1.15.6 via ⬢ v12.18.3 took 7m24s
❯ prisma version
Environment variables loaded from .env
@prisma/cli : 2.13.1
@prisma/client : Not found
Current platform : windows
Query Engine : query-engine fcbc4bb2d306c86c28014f596b1e8c7980af8bd4 (at C:\Users\Southclaws\AppData\Roaming\npm\node_modules\@prisma\cli\node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine : migration-engine-cli fcbc4bb2d306c86c28014f596b1e8c7980af8bd4 (at C:\Users\Southclaws\AppData\Roaming\npm\node_modules\@prisma\cli\node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core fcbc4bb2d306c86c28014f596b1e8c7980af8bd4 (at C:\Users\Southclaws\AppData\Roaming\npm\node_modules\@prisma\cli\node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt fcbc4bb2d306c86c28014f596b1e8c7980af8bd4 (at C:\Users\Southclaws\AppData\Roaming\npm\node_modules\@prisma\cli\node_modules\@prisma\engines\prisma-fmt-windows.exe)
Studio : 0.329.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
What is introspection? (Reference) - Prisma
Write data model into Prisma schema or update existing schema. Introspection workflow. The typical workflow for projects that are not using Prisma Migrate, ......
Read more >Prisma Migrate | Database, Schema, SQL Migration Tool
Prisma Migrate is an imperative database schema migration tool that enables you to: Keep your database schema in sync with your Prisma schema...
Read more >Migration troubleshooting in development - Prisma
This guide describes how to resolve issues with Prisma Migrate in a development environment, which often involves resetting your database.
Read more >Migrating database schema changes | Prisma's Data Guide
In this guide, we'll cover some of the strategies that teams can use to update their database schemas and related codebases and discuss...
Read more >Adding Prisma Migrate to an existing project
Introspect to create or update your Prisma schema. Make sure your Prisma schema is in sync with your database schema. This should already...
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
It seems fixing the double slash comments issue is more complex than we anticipated. Three slashes seems to work better. Hopefully we can look into this soon.
I can confirm this is fixed now. We correct parse
//
in the engines now so this is fixed.