mirror of
https://git.joinfirefish.org/firefish/firefish.git
synced 2024-05-18 08:31:09 +02:00
dev: add script to regenerate sea-orm entities
This commit is contained in:
parent
9fbca3fd95
commit
7c745e09fb
|
@ -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",
|
||||
|
|
28
scripts/regenerate-sea-orm-entities.mjs
Normal file
28
scripts/regenerate-sea-orm-entities.mjs
Normal 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",
|
||||
});
|
||||
})();
|
Loading…
Reference in a new issue