Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init: DBML for those that like visualization #85

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/db/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dbml.svg
schema.dbml
8 changes: 8 additions & 0 deletions packages/db/dbml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { pgGenerate } from "drizzle-dbml-generator";

import * as schema from "./src/schema/index.js";

const out = "./schema.dbml";
const relational = false;

pgGenerate({ schema, out, relational });
2 changes: 1 addition & 1 deletion packages/db/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import baseConfig, {
/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: ["dist/**"],
ignores: ["dist/**", "dbml.ts"],
},
...baseConfig,
...requireJsSuffix,
Expand Down
3 changes: 3 additions & 0 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"with-env": "dotenv -e ../../.env --",
"migrate": "pnpm with-env tsx ./migrate.ts",
"generate": "pnpm with-env drizzle-kit generate",
"generate:erd": "pnpm tsx dbml.ts && pnpm dbml-renderer -i schema.dbml -o erd.svg",
"rest": "pnpm with-env psql $POSTGRES_URL -c \"DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public;\""
},
"dependencies": {
Expand All @@ -49,9 +50,11 @@
"@ctrlplane/eslint-config": "workspace:*",
"@ctrlplane/prettier-config": "workspace:*",
"@ctrlplane/tsconfig": "workspace:*",
"@softwaretechnik/dbml-renderer": "^1.0.30",
"@types/node": "catalog:node22",
"@types/pg": "^8.11.6",
"dotenv-cli": "^7.4.2",
"drizzle-dbml-generator": "^0.9.0",
"drizzle-kit": "^0.24.2",
"eslint": "catalog:",
"prettier": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion packages/db/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"baseUrl": "."
},
"include": ["src", "../api/src/utils", "migrate.ts"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "dbml.ts"]
}
41 changes: 37 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading