AI DEV portal 초기 커밋
Express+EJS+Postgres 사내 개발 포털. - Keycloak OIDC(사번 로그인), GitHub 감성 UI - 사이트 모음 + 프로젝트 공유/코멘트/스타 - DB: OpenEverest appdb portal schema (portal_app role) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
18
scripts/init-db.js
Normal file
18
scripts/init-db.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// schema.sql 을 DATABASE_URL 대상에 적용 (멱등). 사용: npm run db:init
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import pg from "pg";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const sql = fs.readFileSync(path.join(__dirname, "..", "schema.sql"), "utf8");
|
||||
const url = process.env.DATABASE_URL;
|
||||
if (!url) {
|
||||
console.error("DATABASE_URL 미설정 — .project-env 를 로드했는지 확인하세요");
|
||||
process.exit(1);
|
||||
}
|
||||
const client = new pg.Client({ connectionString: url });
|
||||
await client.connect();
|
||||
await client.query(sql);
|
||||
await client.end();
|
||||
console.log("schema.sql 적용 완료");
|
||||
Reference in New Issue
Block a user