dev: add script to regenerate sea-orm entities

This commit is contained in:
naskya 2024-02-21 05:56:43 +09:00
parent 9fbca3fd95
commit 7c745e09fb
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
2 changed files with 30 additions and 1 deletions

View file

@ -32,7 +32,8 @@
"clean": "pnpm node ./scripts/clean-built.mjs",
"clean-npm": "pnpm node ./scripts/clean-npm.mjs",
"clean-cargo": "pnpm node ./scripts/clean-cargo.mjs",
"clean-all": "pnpm run clean && pnpm run clean-cargo && pnpm run clean-npm"
"clean-all": "pnpm run clean && pnpm run clean-cargo && pnpm run clean-npm",
"entities": "pnpm node ./scripts/regenerate-sea-orm-entities.mjs"
},
"dependencies": {
"@bull-board/api": "5.14.1",

View file

@ -0,0 +1,28 @@
import path, { join } from "node:path";
import { fileURLToPath } from "node:url";
import { execa } from "execa";
(async () => {
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// from dev/docker-compose.yml
const POSTGRES_USER = "firefish";
const POSTGRES_PASSWORD = "password";
const POSTGRES_DB = "firefish_db";
const POSTGRES_PORT = "25432";
await execa("pnpm", ["run", "migrate"], {
cwd: join(__dirname, "/.."),
stdio: "inherit",
});
await execa("sea-orm-cli", [
"generate",
"entity",
"--output-dir=src/model/entity",
`--database-url=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${POSTGRES_PORT}/${POSTGRES_DB}`,
], {
cwd: join(__dirname, "/../packages/backend-rs"),
stdio: "inherit",
});
})();