Skip to main content

VS Code 扩展

概述

¥Overview

Prisma VS Code 扩展 拥有超过 250 万的安装量和 35 万的月活跃用户,当你使用 Prisma Postgres 并以 VS Code 作为编辑器构建应用时,它是一款强大的工具。

¥With over 2.5M installs and 350K MAU's, the Prisma VS Code extension is a powerful tool when you're building applications with Prisma Postgres with VS Code as your editor.

数据库管理界面

¥Database management UI

Prisma VS Code 扩展包含一个专用 UI​​,用于管理 Prisma Postgres 实例(本地和远程)。

¥The Prisma VS Code extension includes a dedicated UI to manage Prisma Postgres instances (local and remote).

工作流程

¥Workflows

UI 支持以下工作流程:

¥The UI enables the following workflows:

  • 使用 进行身份验证

    ¥Authenticate with the

  • 查看、创建和删除 Prisma Postgres 实例(本地和远程)

    ¥View, create and delete Prisma Postgres instances (local & remote)

  • "推送到云端":轻松部署本地 Prisma Postgres 实例

    ¥"Push to cloud": Easily deploy a local Prisma Postgres instance

  • 通过嵌入式 Prisma Studio 查看和编辑数据

    ¥View and edit data via an embedded Prisma Studio

  • 可视化你的数据库模式

    ¥Visualize your database schema

用法

¥Usage

要通过 Prisma VS Code 扩展中的 UI 管理 Prisma Postgres 实例:

¥To manage Prisma Postgres instances via the UI in the Prisma VS Code extension:

  1. 确保你已安装最新版本的 Prisma VS Code 扩展

    ¥Ensure you have the latest version of the Prisma VS Code extension installed

  2. 在活动栏中找到 Prisma 徽标

    ¥Find the Prisma logo in the Activity Bar

  3. 点击“登录开始”按钮

    ¥Click the Sign in to get started button

  4. 通过弹出窗口使用 进行身份验证,然后选择目标 workspace

    ¥Authenticate with the via the popup and select a target workspace

内置 Prisma Studio

¥Prisma Studio built-in

除了管理数据库实例之外,Prisma VS Code 扩展还将 Prisma Studio 直接嵌入到你的编辑器中,让你可以轻松地在 VS Code 内部对数据库执行创建、更新和删除操作。按照 简单步骤 开始操作。

¥Beyond managing your database instances, the Prisma VS Code extension embeds Prisma Studio directly in your editor making it easy to perform create, update, delete steps on your database from right inside of VS Code. Follow these easy steps to get started.

代理模式

¥Agent mode

VS Code 包含一个 代理模式(由 GitHub Copilot 提供支持),它会根据你的提示自动执行代码更改并执行 Prisma CLI 命令。

¥VS Code includes an agent mode (powered by GitHub Copilot) that automatically performs code changes and executes Prisma CLI commands based on your prompts.

功能

¥Capabilities

Prisma VS Code 扩展 支持 VS Code 代理模式。

¥The Prisma VS Code extension enables support for VS Code agent mode.

VS Code 代理模式可以执行以下任务:

¥VS Code agent mode can perform the following tasks:

  • 检查迁移状态(例如,标记未应用的迁移)

    ¥Check migration status (e.g. Flag unapplied migrations)

  • 自动创建并应用架构迁移

    ¥Create and apply schema migrations automatically

  • 登录 Prisma 数据平台

    ¥Sign in to the Prisma Data Platform

  • 配置 Prisma Postgres 实例,让你立即开始编码

    ¥Provision Prisma Postgres instances, letting you start coding right away

如何启用和使用 VS Code 代理

¥How to enable and use the VS Code agent

Prisma VS Code 扩展的最新版本 完全支持代理模式。由于扩展会自动更新,因此无需手动操作即可启用它。

¥The latest version of the Prisma VS Code extension fully supports agent mode. Since extensions update automatically, no manual action is required to enable it.

注意

我们建议你使用最新版本的 Prisma ORM。

¥We recommend you to use the latest version of Prisma ORM.

要使用代理模式:

¥To use the agent mode:

  1. 打开 VS Code 中的 GitHub Copilot Chat 并切换到 Agent 模式

    ¥Open GitHub Copilot Chat in VS Code and switch to Agent mode.

  2. 打开 GitHub Copilot Chat 并更新 Prisma 扩展程序后,你只需输入如下请求即可:"为我创建一个新的数据库,并将连接字符串添加到 .env 文件"。

    ¥With GitHub Copilot Chat open and the Prisma extension updated, you can simply type a request such as: "Create a new database for me and add the connection string to the .env file".

  3. 代理将请求在你的工作区中进行更改的权限。

    ¥The agent will request permission to make changes in your workspace.

  4. 它会在继续操作之前自动处理你 Prisma 数据平台账户的登录。

    ¥It automatically handles login to your Prisma Data Platform account before proceeding.

  5. 获得批准后,代理将创建新的数据库并将连接字符串添加到你的 .env 文件中。

    ¥Upon approval, the agent creates the new database and adds the connection string to your .env file.

  6. 你还可以使用代理模式运行迁移、生成 Prisma 客户端以及执行其他任务。

    ¥You can also use agent mode to run migrations, generate the Prisma Client, and perform other tasks.

注意

目前,代理模式使用 Prisma 数据平台中的默认 workspace

¥Currently, the agent mode uses your default workspace in the Prisma Data Platform.

使用 GitHub Copilot 从 VS Code 查询 Prisma 文档

¥Querying Prisma docs from VS Code using GitHub Copilot

作为代理的补充,Prisma Copilot 扩展允许你直接在 VS Code 中查询 Prisma 文档。

¥Complementing the agent, the Prisma Copilot extension allows you to query Prisma documentation directly within VS Code.

你需要从 GitHub 市场安装 Prisma for Copilot 扩展

¥You need to install the Prisma for Copilot extension from the GitHub marketplace.

然后,输入 在 GitHub Copilot Chat 中切换到 Ask 模式 并使用 @prisma-for-github-copilot 命名空间输入你的问题。

¥Then, switch to Ask mode in GitHub Copilot Chat and type your question using the @prisma-for-github-copilot namespace.

更多详细信息,请参阅我们的 GitHub Copilot 文档

¥For more details, refer to our GitHub Copilot documentation.