umijs / umi-blog-example

An example of blog website built with Umi.js and new API route feature in Umi 4.
https://umijs.org/docs/tutorials/blog
38 stars 33 forks source link

执行 npx prisma migrate dev --name init 报错 #10

Open Krystino opened 1 year ago

Krystino commented 1 year ago

各位大佬。我在执行完 npx prisma migrate dev --name init之后,出现了报错。报错信息是:

Error: P3014

Prisma Migrate could not create the shadow database. Please make sure the database user has permission to create databases. Read more about the shadow database (and workarounds) at https://pris.ly/d/migrate-shadow

Original error: 
create database is not supported
   0: migration_core::state::DevDiagnostic
             at migration-engine/core/src/state.rs:251

image

想请问各位大佬应该怎么解决呀?谢谢你们!!

Krystino commented 1 year ago

网上说用这个指令:

npx prisma db push --preview-feature

image 但是问题仍未解决。

XiaoPingzi-Anhui commented 1 year ago

可以再搞一个 数据库作为shadowDatabase,也把链接配置在 .env文件里,同时schema.prisma文件配置如下 generator client { provider = "prisma-client-js" previewFeatures = ["referentialIntegrity"] }

datasource db { provider = "mysql" referentialIntegrity = "prisma" url = env("DATABASE_URL") shadowDatabaseUrl = env("SHADOW_DATABASE_URL") }

Skedush commented 1 year ago

schema.prisma文件的配置有问题,可能是由于prisma升级的原因,用下面这个:

generator client {
    provider = "prisma-client-js"
}

datasource db {
    provider     = "mysql"
    relationMode = "prisma"
    url          = env("DATABASE_URL")
}
...

然后执行命令:

npx prisma db push

就可以了