Skip to content

DB fixed successfully - #8

Merged
TejaBudumuru3 merged 1 commit into
mainfrom
db-main
Nov 21, 2025
Merged

DB fixed successfully#8
TejaBudumuru3 merged 1 commit into
mainfrom
db-main

Conversation

@Vamsi-o

@Vamsi-o Vamsi-o commented Nov 20, 2025

Copy link
Copy Markdown
Contributor

Summary

What changed

  • Describe what you changed and why.

How to test

  • Steps to reproduce / test this PR locally.

Checklist

  • I opened this PR from a feature branch (not main)
  • CI builds and tests pass (no CI configured yet)
  • I added/updated tests if applicable
  • I added documentation if applicable

Reviewers

  • @Vamsi-o (code owner) will be automatically requested to review.

Summary by CodeRabbit

  • Chores
    • Updated database package build process to improve module resolution and dependency initialization.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 20, 2025

Copy link
Copy Markdown

Walkthrough

The build workflow for the @repo/db package has been enhanced to generate Prisma client and include generated Node bindings and runtime assets in the distribution output. Accompanying changes update TypeScript configuration, remove directUrl from the Prisma schema, and refactor path resolution in the entry point to use ES module conventions.

Changes

Cohort / File(s) Summary
Build Configuration
packages/db/package.json, packages/db/tsconfig.json
Updated build script to execute prisma generate, tsc compilation, and copy generated Node bindings and runtime assets to dist. Added module and moduleResolution settings to tsconfig.
Prisma Schema
packages/db/prisma/schema.prisma
Removed directUrl configuration from PostgreSQL datasource block.
Entry Point
packages/db/src/index.ts
Added ES module path utilities (__filename, __dirname via fileURLToPath and path.dirname), reordered imports with PrismaClient at top level, updated dotenv.config() execution order and .env path from ../../.env to ../.env.
Build Metadata
packages/db/tsconfig.tsbuildinfo, packages/trpc/tsconfig.tsbuildinfo
Updated root file lists and build graph metadata. trpc tsbuildinfo version changed from 5.9.2 to 5.7.3.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify the build script copy commands correctly target generated Node bindings and runtime assets
  • Validate ES module path resolution (__filename/__dirname) works correctly with the updated import structure and dotenv configuration
  • Confirm the adjusted .env path (../.env) resolves correctly from the new context
  • Review tsconfig changes (module: ESNext, moduleResolution: Node) for compatibility with the codebase

Possibly related PRs

  • Db Bugging #4: Modifies packages/db/src/index.ts Prisma client initialization and build scripts with overlapping changes to the entry point and build workflow.
  • Checking code rabit #3: Removes directUrl setting from packages/db/prisma/schema.prisma, making an identical schema configuration change.

Suggested reviewers

  • TejaBudumuru3

Poem

🐰 A hop through modules, paths refined,
Prisma bindings bundled, assets aligned,
ESNext brings order, __dirname takes flight,
Build scripts now generate, copying just right!
Onward we build, with the right resolution in sight! 🚀

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'DB fixed successfully' is vague and generic, lacking specific information about what database-related issue was fixed or what changes were made. Replace the title with a specific, descriptive summary such as 'Update DB build workflow to include Prisma generation and bindings' or 'Fix DB package configuration and build process'.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch db-main

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/db/package.json (1)

6-10: Harden build script around copy steps / portability

The prisma generate && tsc -b part is good, but the cp steps assume:

  • cp is available (may not hold on Windows without a POSIX shell).
  • src/generated/*.node always matches at least one file (otherwise cp can fail).
  • dist/generated already exists.

Consider making this more robust by:

  • Using a cross‑platform copy tool (e.g., a small Node script or a CLI like cpy/copyfiles).
  • Ensuring dist/generated is created before copying.
  • Deciding what should happen when there are no .node files (tolerate vs. fail).
packages/db/src/index.ts (1)

3-15: Clarify dotenv loading order and clean up debug logging

A few points around env loading and startup side effects:

  • dotenv.config() is called twice (default on Line 9 and with an explicit path on Line 11). With dotenv’s default override: false, values loaded by the first call will not be overwritten by the second, so ../.env will only fill in missing keys. If the intention was to prefer the package-local .env, you probably want to drop the first call or make the precedence explicit (e.g., single config({ path: ... }), or a second call with override: true).
  • The explicit path path.resolve(__dirname, "../.env") resolves to packages/db/.env at runtime (since __dirname is packages/db/dist). That’s different from a repo‑root .env. Please double‑check that this is the file you actually want to drive DATABASE_URL in all environments.
  • The debug console.debug calls at Lines 14–15 will run on every module import. Given the “Debug — remove after confirming it works” comment, it would be good to remove them or guard them behind a condition (e.g., only in non‑production).

If you’d like to simplify, one possible adjustment (assuming the package-local .env is the source of truth) is:

-import dotenv from "dotenv";
+import dotenv from "dotenv";
@@
-dotenv.config();
-// Load .env explicitly before importing/constructing Prisma
-dotenv.config({ path: path.resolve(__dirname, "../.env") });
+// Load .env explicitly before constructing Prisma
+dotenv.config({ path: path.resolve(__dirname, "../.env") });
@@
-// Debug — remove after confirming it works
-console.debug("packages/db: cwd=", process.cwd());
-console.debug("packages/db: DATABASE_URL present=", !!process.env.DATABASE_URL);
+// Optionally keep this behind an env guard if still needed for troubleshooting
+if (process.env.NODE_ENV === "development") {
+  console.debug("packages/db: cwd=", process.cwd());
+  console.debug("packages/db: DATABASE_URL present=", !!process.env.DATABASE_URL);
+}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2911b70 and 6436876.

📒 Files selected for processing (6)
  • packages/db/package.json (1 hunks)
  • packages/db/prisma/schema.prisma (0 hunks)
  • packages/db/src/index.ts (1 hunks)
  • packages/db/tsconfig.json (1 hunks)
  • packages/db/tsconfig.tsbuildinfo (1 hunks)
  • packages/trpc/tsconfig.tsbuildinfo (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/db/prisma/schema.prisma
🔇 Additional comments (3)
packages/trpc/tsconfig.tsbuildinfo (1)

1-1: TS build metadata change is fine

This is an auto-generated TypeScript build-info file; updated root and version metadata are expected from rebuilding and are safe to commit if you intend to track these artifacts in VCS.

packages/db/tsconfig.json (1)

3-7: ESM compiler options look consistent with package setup

outDir: "./dist" matches "main": "./dist/index.js", and module: "ESNext" with moduleResolution: "Node" is a reasonable choice for a "type": "module" package extending a shared base config. Just confirm the base config sets a modern target/lib compatible with your Node version so the emitted ESM runs as expected.

packages/db/tsconfig.tsbuildinfo (1)

1-1: Updated TS build metadata matches new generated sources

This build-info file now tracks the expanded set of ./src/generated/** and runtime declaration files, which is consistent with running prisma generate as part of the build. No code changes here; fine to keep if tsbuildinfo files are intentionally versioned.

@TejaBudumuru3
TejaBudumuru3 merged commit d326481 into main Nov 21, 2025
2 of 3 checks passed
This was referenced Nov 23, 2025
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants