-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fixed :#2841 NoMongo: Create an equivalent sample database for importation by the setup script #3157
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
Conversation
WalkthroughThis pull request updates the project’s dependency and script configuration in Changes
Sequence Diagram(s)sequenceDiagram
participant S as Setup Script
participant L as loadSampleData.ts
participant FS as File System
participant DB as Database
participant D as Dotenv
S->>L: Initiate sample data loading
L->>D: Call dotenv.config()
L->>FS: Read files from '../../scripts'
FS-->>L: Return list of files
L->>L: Filter and parse .json files
L->>DB: Insert documents into collections
DB-->>L: Confirm insertion
L->>S: Return success message
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Tip 🌐 Web search-backed reviews and chat
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
src/utilities/loadSampleData.ts (1)
165-192
: Add date validation for events.While the event data migration looks good, consider adding these validations:
- Ensure start date is before end date
- Validate that dates are within 2025 (as per PR objectives)
- Check for potential overlapping events
const events = documents.map((event: EventType) => { + const startDate = new Date(event.startAt || new Date()); + const endDate = new Date(event.endAt || new Date()); + + if (startDate > endDate) { + throw new Error(`Invalid date range for event ${event.name}: start date is after end date`); + } + + if (startDate.getFullYear() !== 2025 || endDate.getFullYear() !== 2025) { + throw new Error(`Invalid year for event ${event.name}: all events must be in 2025`); + } + return { ...event, id: uuidv4(), name: event.name, description: event.description, createdAt: event.createdAt ? new Date(event.createdAt) : new Date(), updatedAt: event.updatedAt ? new Date(event.updatedAt) : new Date(), - startAt: event.startAt ? new Date(event.startAt) : new Date(), - endAt: event.endAt ? new Date(event.endAt) : new Date(), + startAt: startDate, + endAt: endDate,
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
package.json
(5 hunks)src/utilities/loadSampleData.ts
(8 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyse Code With CodeQL (typescript)
🔇 Additional comments (5)
src/utilities/loadSampleData.ts (2)
4-4
: LGTM! Environment configuration is properly set up.The addition of dotenv configuration is appropriate for managing PostgreSQL connection parameters.
Also applies to: 10-10
96-141
: LGTM! Robust implementation of user and organization data migration.The implementation correctly handles:
- UUID generation for IDs
- Unique constraints (email addresses, organization names)
- Foreign key relationships between users and organizations
- Date conversions
package.json (3)
109-112
: LGTM! Scripts are properly configured.The new scripts align well with the PR objectives:
- setup: For initial configuration
- import:sample-data: For importing PostgreSQL sample data
- export:data: For exporting data to JSON
24-24
: Verify compatibility of downgraded packages.The following packages have been downgraded:
- drizzle-orm: ^0.39.1 → ^0.38.4
- drizzle-seed: ^0.3.1 → ^0.3.0
Also applies to: 55-55
✅ Verification successful
🌐 Web query:
Are there any breaking changes or known issues between drizzle-orm 0.38.4 and 0.39.1?
💡 Result:
When upgrading from Drizzle ORM 0.38.4 to 0.39.1, there are several breaking changes and known issues to consider: ### Breaking Changes 1. **Bun SQL Driver Compatibility** - Requires Bun v1.2+ but has unresolved concurrency issues for simultaneous queries[1][9]. - Limited type handling: - `json`/`jsonb` inserts/selects require manual `JSON.stringify`[1]. - `datetime`, `date`, and `timestamp` types fail in `mode: string`[1]. - Array types may malfunction[1]. 2. **Drizzle-Kit Version Lock** - Drizzle-Kit must be updated to **0.30.x** (e.g., 0.30.4) to avoid errors like `This version of drizzle-kit requires newer version of drizzle-orm`[4][5]. Earlier versions (e.g., 0.28.x) are incompatible with ORM ≥0.39.x. 3. **CTE (WITH Clause) Syntax** - `WITH` now supports `INSERT`, `UPDATE`, `DELETE`, and raw SQL templates, requiring syntax adjustments for existing CTE queries[1]. ### Known Issues | Issue | Description | Source | |-------|-------------|--------| | **Bun SQL Driver Limitations** | JSON/array handling requires workarounds; datetime parsing broken | [1][9] | | **Drizzle-Zod Compatibility** | Schema generation may produce nullable fields in v0.6.x (fixed via type coercion)[10] | [10] | | **SingleStore Migrations** | Schema changes may require table recreation for older schemas[5] | [5] | For migrations, ensure **[email protected]** is paired with **[email protected]**, and test Bun SQL integrations thoroughly due to unresolved driver limitations[1][4][9]. Citations: - 1: https://github.com/drizzle-team/drizzle-orm/releases - 2: https://www.youtube.com/watch?v=fDjZOZ1Hgf8 - 3: https://github.com/drizzle-team/drizzle-orm/issues/2418 - 4: https://github.com/drizzle-team/drizzle-orm/issues/3578 - 5: https://newreleases.io/project/github/drizzle-team/drizzle-orm/release/[email protected] - 6: https://orm.drizzle.team/docs/latest-releases - 7: https://orm.drizzle.team/docs/overview - 8: https://orm.drizzle.team/docs/latest-releases/drizzle-orm-v0290 - 9: https://newreleases.io/project/npm/drizzle-orm/release/0.39.0 - 10: https://www.answeroverflow.com/m/1318734467082354689
Downgrade Validated
The downgrade from drizzle-orm 0.39.1 to 0.38.4 avoids the breaking changes introduced in v0.39.1—such as Bun SQL driver compatibility issues, type handling adjustments, enforced drizzle-kit upgrades, and CTE syntax changes—thereby maintaining compatibility with our existing code. Similar reasoning applies to the drizzle-seed downgrade.
7-11
: Verify the necessity of Docusaurus packages.These packages seem unrelated to the PR's objective of creating a sample PostgreSQL database:
- @docusaurus/* packages
- prism-react-renderer
Also applies to: 37-37
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
src/utilities/loadSampleData.ts (1)
35-36
: 🧹 Nitpick (assertive)Add directory existence validation and improve error handling
Consider adding a check to verify that the
sampleDataPath
exists before attempting to read it. This will enhance error handling for scenarios such as the directory not being found.Apply this diff to add the validation:
try { const sampleDataPath = path.resolve(dirname, "../../scripts"); + const pathExists = await fs.access(sampleDataPath).then(() => true).catch(() => false); + if (!pathExists) { + throw new Error(`Sample data directory not found: ${sampleDataPath}`); + } const files = await fs.readdir(sampleDataPath);
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/utilities/loadSampleData.ts
(8 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyse Code With CodeQL (typescript)
🔇 Additional comments (3)
src/utilities/loadSampleData.ts (3)
4-4
: Approved: Correct usage of dotenv for environment variablesThe addition of the
dotenv
package and initializing it withdotenv.config()
is a good practice for managing environment variables.Also applies to: 10-10
41-45
: Simplified file filtering and logging looks goodThe update to filter files by
.json
extension and the simplification of the logging format improves readability.
205-212
: 🛠️ Refactor suggestionReview process exit handling and error management
The current implementation may lead to confusion in exit codes and error handling:
process.exit(1)
is called in thecatch
block when an error occurs.process.exit(0)
is called after thefinally
block, which might execute regardless of errors.Consider adjusting the placement of
process.exit(0)
and ensuring thatqueryClient.end()
is called correctly, to prevent masking errors and maintain consistent exit behavior.Apply this diff to improve the exit handling:
} catch (error) { console.error("Failed to import sample data:", error); + await queryClient.end().catch(console.error); process.exit(1); } finally { - await queryClient.end().catch(console.error); } - process.exit(0); + console.log("\nTables populated successfully"); + await queryClient.end().catch(console.error); + process.exit(0);Likely invalid or redundant comment.
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (1)
package.json
(6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyse Code With CodeQL (typescript)
🔇 Additional comments (16)
package.json (16)
23-24
: Environment and ORM Dependency Update.
The addition of"dotenv": "^16.4.7"
supports managing environment variables, and the downgrade of"drizzle-orm"
to^0.38.4
appears to address compatibility concerns. Ensure these version adjustments resolve any related issues without introducing regressions elsewhere.
49-49
: Type Definitions for Inquirer.
Adding"@types/inquirer": "^9.0.7"
improves TypeScript support forinquirer
. This is a good addition for improved developer experience.
50-50
: Type Definitions for Jest.
The new dependency"@types/jest": "^29.5.14"
enhances type safety for Jest tests. Make sure your tests are updated accordingly.
51-51
: Updated Node Type Definitions.
Upgrading"@types/node"
to version^22.13.0
aligns with the engine requirements listed in the project. Please verify that the change is fully compatible with your current Node environment.
52-52
: Type Definitions for React.
The inclusion of"@types/react": "^18.3.18"
supports React-based components. Confirm that this addition is relevant for the repository, particularly if React is used in any frontend or visualization components.
54-54
: Biome Dependency for Code Quality.
Adding"biome": "^0.3.3"
helps enforce code quality standards. Make sure its integration within the project’s quality check scripts performs as expected.
56-56
: Drizzle-Seed Downgrade.
The version of"drizzle-seed"
has been downgraded to^0.3.0
. This change likely addresses compatibility issues with the database seeding process. Please revalidate the seeding functionality after this change.
58-58
: Jest Testing Framework Added.
Introducing"jest": "^29.7.0"
for testing purposes is a positive move. Ensure that the test runner and configurations are updated to leverage this version.
59-59
: Jest Extended Library Added.
The dependency"jest-extended": "^4.0.2"
provides additional Jest matchers, enhancing the testing assertions. Confirm that your tests utilize these extended assertions as needed.
63-63
: TS-Jest for TypeScript Testing.
Adding"ts-jest": "^29.2.5"
assists in running TypeScript tests with Jest. Verify that the configuration forts-jest
is properly set up in your project.
82-82
: Package Manager Version Update.
ThepackageManager
has been updated to"[email protected]"
from the previous version. This deliberate downgrade might be addressing specific compatibility requirements. Ensure that all contributors are informed about and using this version for consistency.
91-91
: Updated Code Quality Check Script.
The"check_code_quality"
script now invokespnpm biome check --error-on-warnings
. Confirm that this change fits your CI/CD setup and that the biome tool is correctly installed as a dependency.
104-104
: Drizzle Studio Script Added.
The addition of the"start_drizzle_studio": "drizzle-kit studio"
script provides a convenient way to launch the Drizzle Studio UI. Verify thatdrizzle-kit
is correctly configured and that the studio launches without issues.
111-111
: Import Sample Data Script Reintroduced.
The"import:sample-data": "tsx ./src/utilities/loadSampleData.ts"
script reintroduces the sample data import command with an updated path. Please confirm that the new file location and import logic function correctly.
112-112
: Upgrade Drizzle Metadata Script.
The"upgrade_drizzle_metadata": "drizzle-kit up"
command now manages the upgrade of Drizzle’s metadata. Validate that this change synchronizes with your database migration strategy and updates metadata as intended.
113-113
: Export Data Script Added.
The new script"export:data": "tsx ./scripts/convertToJson.ts"
facilitates exporting data to JSON. Ensure that the generated output meets the expected format and that the conversion logic is robust.
"@docusaurus/core": "^3.7.0", | ||
"@docusaurus/preset-classic": "^3.7.0", | ||
"@docusaurus/theme-classic": "^3.7.0", | ||
"@docusaurus/tsconfig": "^3.7.0", | ||
"@docusaurus/types": "^3.7.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Docusaurus Dependencies Added.
The new Docusaurus dependencies (@docusaurus/core
, @docusaurus/preset-classic
, @docusaurus/theme-classic
, @docusaurus/tsconfig
, and @docusaurus/types
) have been introduced at version ^3.7.0
. Please verify whether these packages are required in the production bundle or if they can be moved to devDependencies
to reduce the production footprint.
"drizzle-zod": "0.6.1", | ||
"env-schema": "^6.0.1", | ||
"fastify": "^5.2.1", | ||
"fastify-plugin": "^5.0.1", | ||
"graphql": "^16.10.0", | ||
"graphql-scalars": "^1.24.0", | ||
"graphql-upload-minimal": "^1.6.1", | ||
"inquirer": "^12.3.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Inquirer Dependency Added.
The inclusion of "inquirer": "^12.3.2"
provides support for interactive CLI operations. Consider confirming whether this dependency is needed in production or if it should be listed under devDependencies
when its usage is limited to scripts or development-time interactions.
"mercurius": "^16.0.1", | ||
"mercurius-upload": "^8.0.0", | ||
"minio": "^8.0.4", | ||
"postgres": "^3.4.5", | ||
"prism-react-renderer": "^2.4.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Prism React Renderer Dependency.
The new dependency "prism-react-renderer": "^2.4.1"
is likely used for code syntax highlighting in documentation or tooling interfaces. As with other similar libraries, verify if it would be better placed under devDependencies
based on its usage.
"run_tests": "vitest --coverage", | ||
"start_development_server": "tsx watch ./src/index.ts", | ||
"start_development_server_with_debugger": "tsx watch --inspect=${API_DEBUGGER_HOST:-127.0.0.1}:${API_DEBUGGER_PORT:-9229} ./src/index.ts", | ||
"start_production_server": "pnpm build_production && node ./dist/index.js", | ||
"start_production_server_with_debugger": "pnpm build_production && node --inspect=${API_DEBUGGER_HOST:-127.0.0.1}:${API_DEBUGGER_PORT:-9229} ./dist/index.js", | ||
"upgrade_drizzle_metadata": "drizzle-kit up" | ||
"setup": "tsx setup.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Setup Script Introduced.
The "setup": "tsx setup.ts"
script is introduced to streamline the initialization process, likely in regard to setting up the PostgreSQL sample database. Ensure that setup.ts
is well-tested and covers the necessary setup procedures.
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
@palisadoes @pateldivyesh1323 please add git-ignore label to this pr i will check remaining failing cases |
I'm going to close this. @gautam-divyanshu got the DB importation working |
What kind of change does this PR introduce?
Feature: Recreate sample PostgreSQL database for the
develop-postgres
branch.Issue Number:
Fixes #2841
Snapshots/Videos:
N/A
If relevant, did you update the documentation?
Yes, updated
INSTALLATION.md
with user information.Summary
This PR recreates a sample PostgreSQL database for the
develop-postgres
branch, ensuring compatibility with the setup script. It includes:develop
branch implementation..env
file setup script #2840 for.env
file setup.INSTALLATION.md
.Does this PR introduce a breaking change?
No
Checklist
CodeRabbit AI Review
Test Coverage
Other information
N/A
Have you read the contributing guide?
Yes
Summary by CodeRabbit
Chores
Refactor
New Features