Comments (10)
The files in prisma/migrations
exist.
I decided to move the models to the prisma/schema folder, the problem disappeared.
Before this, the models were in the prisma root folder, and there was also a migrations
folder.
At now i set current structure of prisma folder.
Thanks a lot.
from prisma.
No, there is definitely a problem when using --schema prisma
that we need to reproduce and fix.
But thanks for the information, we will take it from here.
from prisma.
Hm, let's figure out what really is unexpected here.
You first show that you have no migrations in prisma/migrations
, and then you run prisma migrate dev
on a database that already has tables in there (which conflicts with the fact that there are not existing migrations) and also has recordings that there should be migrations that were applied to the database in the past (The following migration(s) are applied to the database but missing from the local migrations directory ...
), so Prisma tells you that your database is in a drift state and suggests a reset to get your database into a clean state. That is normal, and could potentially be worked around with https://www.prisma.io/docs/orm/prisma-migrate/workflows/baselining if you really wanted.
All of this of course only makes sense if you indeed do not have local migrations in a migration directory. Is that really the case? You mentioned that you split your Prisma schema. Where did you put these files? The default folder to put them would be prisma/schema
while the migrations stay in prisma/migrations
.
Did you put the files directly in prisma
instead, and that is the reason for --schema prisma
in your commands?
from prisma.
So just to confirm, you tried to use ./prisma
as the folder for prismaSchemaFolder
and that led to problems?
from prisma.
So just to confirm, you tried to use
./prisma
as the folder forprismaSchemaFolder
and that led to problems?
Yes, there were *.prisma
files and the folder with migrations in ./prisma
folder.
from prisma.
Ok, I understand. Seems that using --schema prisma
leads to the CLI not picking up the migrations folder any more, even though it tells you it is looking in the correct path. That is super unexpected.
from prisma.
Just in case
I ran command without --schema
options after I moved *.prisma
files to prisma/schema
folder.
But yes it ignore prisma/migrations
folder if i will set --schema=prisma
from prisma.
I ran command without
--schema
options after I moved*.prisma
files toprisma/schema
folder.
Interesting, to me it is unclear how that should treat multiple .prisma
files in that folder and what should happen.
How did that work when you used the commands without --schema
completely?
from prisma.
I found out.
The migrations
folder should not be in the same folder as *.prisma
files.
Then everything will work.
I think there is nothing to worry about anymore.
from prisma.
I confirm,
When use
npx prisma migrate dev --create-only --skip-generate --schema prisma
Prisma prefer to reset database.
It doesn't matter how the files are located, the problem still occurs.
My project structure
![image](https://github.com/prisma/prisma/assets/37801096/5a08ecc4-7a95-4956-a4a3-5f861b0f0246)My main.prisma file
// 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"
previewFeatures = ["prismaSchemaFolder"]
}
datasource db {
provider = "postgresql"
url = env("DB_URL")
}
geo.prisma as example
model Country {
id Int @id @default(autoincrement()) @db.Integer
name String @unique @db.VarChar(255)
color String @db.Char(7)
code String? @db.VarChar(255)
regions Region[]
@@map("countries")
}
enum GeoObjectTypeEnum {
COUNTRY @map("country")
REGION @map("region")
CITY @map("city")
DISTRICT @map("district")
@@map("geo_object_type_enum")
}
model Region {
id Int @id @default(autoincrement()) @db.Integer
name String @db.VarChar(255)
country Country @relation(fields: [countryId], references: [id], onDelete: Cascade, onUpdate: Cascade)
countryId Int @map("country_id") @db.Integer
color String @db.Char(7)
code Int? @db.Integer
cities City[]
@@unique(fields: [countryId, name, code], map: "regions_country_id_name", name: "regionUniqueName")
@@map("regions")
}
model City {
id Int @id @default(autoincrement()) @db.Integer
name String @db.VarChar(255)
region Region @relation(fields: [regionId], references: [id], onDelete: Cascade, onUpdate: Cascade)
regionId Int @map("region_id") @db.Integer
color String @db.Char(7)
code Int? @unique @db.Integer
districts District[]
levelGeography LevelGeography[]
cityCoordinates CityCoordinates?
cityCounting1Day CityCounting1Day[]
cityCounting1Week CityCounting1Week[]
cityCounting1Month CityCounting1Month[]
cityCounting1Year CityCounting1Year[]
@@unique(fields: [regionId, name, code], map: "cities_unique_fields", name: "cityUniqueFields")
@@map("cities")
}
model District {
id Int @id @default(autoincrement()) @db.Integer
name String @db.VarChar(255)
city City @relation(fields: [cityId], references: [id], onDelete: Cascade, onUpdate: Cascade)
cityId Int @map("city_id") @db.Integer
color String @db.Char(7)
levelGeography LevelGeography[]
districtCoordinates DistrictCoordinates?
districtCounting1Day DistrictCounting1Day[]
districtCounting1Week DistrictCounting1Week[]
districtCounting1Month DistrictCounting1Month[]
districtCounting1Year DistrictCounting1Year[]
@@unique(fields: [name, cityId], name: "districtUniqueFields", map: "districts_unique")
@@map("districts")
}
model CityCoordinates {
id Int @id @default(autoincrement()) @db.Integer
lat Float @db.DoublePrecision
lon Float @db.DoublePrecision
city City @relation(fields: [cityId], references: [id], onDelete: Cascade, onUpdate: Cascade)
cityId Int @unique @map("city_id") @db.Integer
weather CityCoordinateWeatherForecast[]
@@map("cities_coordinates")
}
model DistrictCoordinates {
id Int @id @default(autoincrement()) @db.Integer
lat Float @db.DoublePrecision
lon Float @db.DoublePrecision
district District @relation(fields: [districtId], references: [id], onDelete: Cascade, onUpdate: Cascade)
districtId Int @unique @map("district_id") @db.Integer
weather DistrictCoordinateWeatherForecast[]
@@map("districts_coordinates")
}
from prisma.
Related Issues (20)
- Database migration error HOT 3
- `migrate diff` complains about schema not listed even though it is present HOT 1
- `prisma:engine:db_query` span missing for `count`/`aggregate` with MongoDB
- Prisma `Unsupported()` columns can be overwritten HOT 5
- Type issue where field is not null HOT 2
- Missing generated Enum in typescript definition when Enum isn't used in Prisma table
- internal error: entered unreachable code HOT 2
- Edge runtime incompatibility error on `$on` or `$use` usage attempt HOT 4
- Return a proper error code and description when encountering zero dates
- Filtering by relationship using "some" results in inefficient queries due to un-correlated sub queries HOT 2
- Support nested queries in `query` extension
- Not possible to omit optional fields in Mongo HOT 2
- Inconsistent execution times for Prisma Generate command HOT 8
- called `Option::unwrap()` on a `None` value HOT 2
- Bug (D1 migrations): IDs of optional relations are lost quietly during migration HOT 3
- prisma migrate dev fails with Error: P1017 (prisma > 5.9.1) HOT 2
- MySQL migration invalid default value @default(now())
- Bug: [D1] Error in performIO: Error: D1_ERROR: too many SQL variables HOT 1
- Support Couchbase HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisma.