项目简介
DrawDB 是一款免费、简单直观的数据库实体关系图(ERD)编辑器,完全在浏览器中运行。无需注册即可绘制图表、生成 SQL 脚本和导出迁移,支持 PostgreSQL、MySQL、SQLite 等多种数据库。
README 预览
\n Special thanks to:\n \n \n \n \n Next-gen AI-powered intelligent terminal for all platforms\n \n\n\n\n\n\n\n \n drawDB\n\n\nFree, simple, and intuitive database schema editor and SQL generator.\n\n\n \n \n \n \n \n \n \n \n \n\n\n\n\nDrawDB is a robust and user-friendly database entity relationship diagram (ERD) editor right in your browser. Build diagrams with a few clicks, export and import SQL scripts, generate migrations, customize your editor, and more without creating an account. See the full set of features on [here](https://drawdb.app/).\n\n## Getting Started\n\n### Local Development\n\n```bash\ngit clone https://github.com/drawdb-io/drawdb\ncd drawdb\nnpm install\nnpm run dev\n```\n\n### Build\n\n```bash\ngit clone https://github.com/drawdb-io/drawdb\ncd drawdb\nnpm install\nnpm run build\n```\n\n### Docker Build\n\n```bash\ndocker build -t drawdb .\ndocker run -p 3000:80 drawdb\n```\n\nIf you want to enable sharing, set up the [server](https://github.com/drawdb-io/drawdb-server) and environment variables according to `.env.sample`. This is optional unless you need to share files.\n\n## Contributing\n\nPlease see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute to this project.\n\n## Support\n- Join discussions: [Discord](https://discord.gg/BrjZgNrmR6)\n
常见问题 (4)
故障排除为什么 DrawDB Docker 会忽略 VITE_BACKEND_URL,并向 /diagrams/undefined/gists 发送 POST 请求?
Vite 会在构建时替换 import.meta.env.VITE_BACKEND_URL,因此较旧的 DrawDB 镜像无法通过 docker run 读取 -e VITE_BACKEND_URL=...。请更新到包含运行时配置修复的镜像,然后启动一个新容器:
docker pull ghcr.io/drawdb-io/drawdb:latest
docker run -d --name drawdb \
-p 3024:80 \
-e VITE_BACKEND_URL=https://api.example.com \
ghcr.io/drawdb-io/drawdb:latest
使用不带尾部斜杠的后端源地址。启动后,强制刷新浏览器(Ctrl+Shift+R)以避免使用缓存的配置。在 DevTools 中,Share/Gist 请求应发送到 https://api.example.com/diagrams/.../gists,而不是 http://localhost:3024/editor/diagrams/undefined/gists。
Docker Compose 等效配置:
services:
drawdb:
image: ghcr.io/drawdb-io/drawdb:latest
ports:
- "3024:80"
environment:
VITE_BACKEND_URL: https://api.example.com
在没有该修复的旧镜像上,该变量必须在镜像构建期间就已存在——例如在运行 docker build 之前将其添加到 .env 中——因为仅在容器运行时设置该变量不会产生任何效果。
故障排除如何修复颜色选择器在光标移出其边界时关闭的问题?
从外层 ColorPicker 包裹容器中移除 onMouseLeave 事件处理函数。例如,从包裹的 div 中删除 onMouseLeave={handleColorPick}。选择器应仅在真正点击其外部时关闭,而不是在选择颜色过程中鼠标暂时移出其边界时关闭。
故障排除为什么在 drawDB 中只重命名或编辑一个 enum 时,所有导入的 PostgreSQL enums 都会发生变化?
出现这种情况是因为导入的 PostgreSQL 枚举对象没有获得唯一的 ID,因此 drawDB 在编辑时将它们视为同一个对象。修复方法是在 fromPostgres 导入函数中创建每个枚举时添加唯一的 ID,例如:enums.push({ id: nanoid(), name, values })。请将 drawDB 更新到包含 issue #1141 修复的版本。如果是自托管部署,请修补 fromPostgres 中的 PostgreSQL 枚举创建步骤,为每个导入的枚举调用 nanoid()。
故障排除如何修复 drawdb.app 显示空白主页并出现 "TypeError: n is not iterable" 错误的问题?
这是 drawdb 的一个生产环境 JavaScript bug,并非浏览器特有的问题;它影响了 Chrome、Firefox、Edge、Safari 和 Vivaldi。维护者已部署修复。如果网站仍然显示空白,请使用 Ctrl+F5(Windows/Linux)或 Cmd+Shift+R(macOS)强制重新加载最新资源,清除缓存的站点数据,或尝试使用无痕/隐私窗口。对于自托管实例,请更新到最新的 drawdb 发布版本/镜像并重新构建或重启,例如:docker compose pull && docker compose up -d。