错误:P3017 当我运行 npx prisma 命令

huangapple go评论54阅读模式
英文:

Error: P3017 When I run npx prisma command

问题

当我在命令行中输入 npx prisma migrate resolve --applied 0_init 时,出现以下错误:

**错误:P3017

无法找到迁移 0_init。请确保迁移存在,并且您包括了整个目录名称。(示例:“20201207184859_initial_migration”)**

我想在我的Next.js项目中使用MySQL表格。

根据此链接,我可以使用Prisma ORM 来实现这一点。

但我在这一步卡住了:npx prisma migrate resolve --applied 0_init

英文:

when I hit npx prisma migrate resolve --applied 0_init in command line. bellow error occurred:

**Error: P3017

The migration 0_init could not be found. Please make sure that the migration exists, and that you included the whole name of the directory. (example: "20201207184859_initial_migration")**

I want to use mysql tables in my own next js project .

According to this url, I can do that using prisma orm.

but Im stock in this step : npx prisma migrate resolve --applied 0_init

答案1

得分: 3

Change migration.sql 文件编码为 window1252

在VScode中:

  • 打开 migration.sql 文件
  • 打开命令面板 (Ctrl+Shift+P),搜索 "Change File Encoding"
  • 选择 "Save with encoding"
  • 选择 "window1252"

从这个帖子:https://github.com/prisma/prisma/issues/17558

他们发现问题是由于 migration.sql 文件的编码引起的。
文件编码由执行 npx prisma migrate diff > migration.sql 命令时使用的 shell 决定。

在Powershell中执行时,它使用utf16编码写入 migration.sql 文件。在CMD中执行时,它使用window1252编写文件。

英文:

Change migration.sql file encoding to window1252.

In VScode:

  • Open the migration.sql file
  • open command palette (Ctrl+Shift+P) and search for "Change File Encoding"
  • select "Save with encoding"
  • select "window1252"

From this thread : https://github.com/prisma/prisma/issues/17558

They found the issue was caused by migration.sql file encoding.
The file encoding is determined by the shell used when executing the npx prisma migrate diff > migration.sql command.

When executed in Powershell, it writes the migration.sql file using utf16 encoding. When executed in CMD it writes the file using window1252.

答案2

得分: 0

我刚刚遇到了和你一样的问题。我的环境是:在Windows10上使用VSCode1.78。
我在默认情况下使用的是PowerShell终端,然后卡住了。

幸运的是,我从这个帖子的评论中得到了灵感:
https://github.com/prisma/prisma/issues/17558

然后我切换到在VSCode中使用“cmd”终端来执行相同的命令,问题就消失了。

所以我确信问题是由于PowerShell终端和“cmd”终端之间的某些差异引起的。

顺便说一下,我在VSCode之外的Git Bash终端中尝试了“npx prisma migrate resolve --applied 0_init”命令,一切都很顺利。

英文:

I just encounted exactly the same issue as yours. My environment: VSCode1.78 on a Windows10 .
I was struck in my VSCode terminal, which by default is a powershell.

Fortunately I got inspiration from comments to the end of this thread:
https://github.com/prisma/prisma/issues/17558

Then I switched to a "cmd" terminal in VSCode to execute the same command, and the problem just disappeared.

So I am sure the problem was caused by some difference between Powshell terminal and "cmd" terminal.

By the way, I tried the "npx prisma migrate resolve --applied 0_init" command in a git bash terminal outside of VSCode. All good there too.

huangapple
  • 本文由 发表于 2023年5月24日 17:16:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76321912.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定