Skip to content
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

chore: update packages + migrate to prisma 5 #145

Closed
wants to merge 20 commits into from

Conversation

arian81
Copy link
Member

@arian81 arian81 commented Oct 7, 2023

Summary by CodeRabbit

  • New Features
    • Upgraded Node.js version used in the workflow for improved performance and security.
    • Introduced a new database provider for enhanced database management.
    • Enhanced the Applicant component to set the alreadyReviewed state based on certain conditions.
    • Improved QRScanner components with additional arguments for better functionality.
  • Bug Fixes
    • Fixed syntax errors across multiple files for smoother code execution.
    • Corrected a typo in the parseTime function in parseIcsSchedule.ts for accurate date construction.
  • Refactor
    • Updated database schema in prisma/schema.prisma for better data handling.
  • Style
    • Implemented code formatting and style changes across multiple files for improved code readability.

@linear
Copy link

linear bot commented Oct 7, 2023

TECH-47 Migrate to Prisma V5

There's a new major version of Prisma and there's performance improvements based on the change logs

@netlify
Copy link

netlify bot commented Oct 7, 2023

Deploy Preview for profound-kringle-30b3e4 failed.

Name Link
🔨 Latest commit 93a8e62
🔍 Latest deploy log https://app.netlify.com/sites/profound-kringle-30b3e4/deploys/6545d2ff013d02000804863e

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 26, 2023

Walkthrough

The changes primarily involve minor syntax adjustments, such as adding trailing commas and fixing minor typos. There are also significant changes to the Prisma schema file, including a change in the database provider and modifications to several models. Additionally, there are updates to the Node.js version in the GitHub Actions workflow and changes to the logic in some React components.

Changes

File(s) Summary
.github/workflows/PR-CI.yaml Updated the Node.js version from 16 to 20 in the GitHub Actions workflow.
prisma/schema.prisma Changed the database provider from "postgresql" to "cockroachdb". Commented out the @db.Text annotations for several fields in the Account and User models.
src/components/Applicant.tsx, src/components/QrScanner.tsx, src/components/QrScanner2.tsx, src/components/RBACWrapper.tsx Made changes to the logic in some React components and added missing commas.
src/env/client.mjs, src/env/server.mjs Added commas after parameters in function signatures.
src/pages/... Added commas after parameters in function signatures and made minor changes to the logic in some components.
src/server/router/... Added missing commas and fixed minor typos.
src/utils/parseIcsSchedule.ts, src/utils/parseTsvSchedule.ts Fixed a typo in the slice indices and added a comma after a parameter in a function signature.

Poem

🍂 As autumn leaves fall, so do old ways, 🍁

In code we trust, in code we gaze. 🖥️

Comma here, comma there, making things neat, 🖋️

With every change, we skip a beat. 💓

Node version up, from 16 to 20, 🚀

Making our code more robust and plenty. 💪

As the moon rises, we end our day, 🌙

Celebrating changes, in a whimsical way. 🎉


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 01ae87d and e3cd7e3.
Files ignored due to filter (2)
  • package-lock.json
  • package.json
Files selected for processing (26)
  • .github/workflows/PR-CI.yaml (1 hunks)
  • prisma/schema.prisma (3 hunks)
  • src/components/Applicant.tsx (2 hunks)
  • src/components/QrScanner.tsx (1 hunks)
  • src/components/QrScanner2.tsx (1 hunks)
  • src/components/RBACWrapper.tsx (2 hunks)
  • src/env/client.mjs (2 hunks)
  • src/env/server.mjs (1 hunks)
  • src/pages/admin.tsx (1 hunks)
  • src/pages/api/cal.ts (1 hunks)
  • src/pages/api/resumes/[...path].ts (1 hunks)
  • src/pages/apply.tsx (1 hunks)
  • src/pages/checkin.tsx (1 hunks)
  • src/pages/dashboard.tsx (1 hunks)
  • src/pages/grade.tsx (5 hunks)
  • src/pages/me.tsx (1 hunks)
  • src/pages/roles.tsx (1 hunks)
  • src/pages/scanner.tsx (6 hunks)
  • src/pages/welcome.tsx (1 hunks)
  • src/server/router/application.ts (2 hunks)
  • src/server/router/context.ts (1 hunks)
  • src/server/router/events.ts (1 hunks)
  • src/server/router/reviewers.ts (10 hunks)
  • src/server/router/sponsors.ts (5 hunks)
  • src/utils/parseIcsSchedule.ts (1 hunks)
  • src/utils/parseTsvSchedule.ts (1 hunks)
Files skipped from review due to trivial changes (24)
  • .github/workflows/PR-CI.yaml
  • src/components/Applicant.tsx
  • src/components/QrScanner.tsx
  • src/components/QrScanner2.tsx
  • src/components/RBACWrapper.tsx
  • src/env/client.mjs
  • src/env/server.mjs
  • src/pages/admin.tsx
  • src/pages/api/cal.ts
  • src/pages/api/resumes/[...path].ts
  • src/pages/apply.tsx
  • src/pages/checkin.tsx
  • src/pages/dashboard.tsx
  • src/pages/grade.tsx
  • src/pages/me.tsx
  • src/pages/roles.tsx
  • src/pages/welcome.tsx
  • src/server/router/application.ts
  • src/server/router/context.ts
  • src/server/router/events.ts
  • src/server/router/reviewers.ts
  • src/server/router/sponsors.ts
  • src/utils/parseIcsSchedule.ts
  • src/utils/parseTsvSchedule.ts
Additional comments: 8
prisma/schema.prisma (2)
  • 9-9: The database provider has been changed from "postgresql" to "cockroachdb". Ensure that the CockroachDB is set up correctly and all the necessary migrations have been performed. Also, verify that the application's database-related functionality works as expected with the new provider.

  • 56-56: The @db.Text annotations have been commented out in the Account and User models. This change is likely due to the migration from PostgreSQL to CockroachDB, as the @db.Text annotation is specific to PostgreSQL, MySQL, and SQL Server. Ensure that the data types of these fields in the CockroachDB schema match the expected data types in the application. Also, verify that the application's functionality related to these fields works as expected.

src/pages/scanner.tsx (6)
  • 25-25: The addition of a trailing comma in the object literal is a minor change that aligns with the ES6 standard for trailing commas in multiline object literals and arrays. This change improves code readability and makes future diffs cleaner.

  • 66-66: The addition of a trailing comma in the dependency array of the useCallback hook is a minor change that aligns with the ES6 standard for trailing commas in multiline arrays. This change improves code readability and makes future diffs cleaner.

  • 169-169: The addition of a trailing comma in the options object passed to the useQuery hook is a minor change that aligns with the ES6 standard for trailing commas in multiline object literals. This change improves code readability and makes future diffs cleaner.

  • 271-271: The addition of a trailing comma in the options object passed to the useQuery hook is a minor change that aligns with the ES6 standard for trailing commas in multiline object literals. This change improves code readability and makes future diffs cleaner.

  • 311-311: The addition of a trailing comma in the arguments of the replace method is a minor change that aligns with the ES6 standard for trailing commas in multiline function arguments. This change improves code readability and makes future diffs cleaner.

  • 606-606: The addition of a trailing comma in the parameters of the getServerSideProps function is a minor change that aligns with the ES6 standard for trailing commas in multiline function parameters. This change improves code readability and makes future diffs cleaner.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e3cd7e3 and 1eb5e74.
Files selected for processing (1)
  • prisma/schema.prisma (2 hunks)
Additional comments: 8
prisma/schema.prisma (8)
  • 1-8: The database provider has been changed from "postgresql" to "cockroachdb". Ensure that the CockroachDB is set up correctly and the DATABASE_URL environment variable is updated accordingly. Also, verify that all the database operations are compatible with CockroachDB.

  • 10-30: The Account model remains largely unchanged, but the user field has been renamed to User to match the naming convention of other relation fields. This change should not affect the functionality, but make sure to update any references to this field in the codebase.

  • 32-38: The EventLog model remains unchanged. No action needed.

  • 40-47: The Review model has been updated. The hacker and reviewer fields have been replaced with User_Review_hackerIdToUser and User_Review_reviewerIdToUser respectively. These changes reflect the new relations between the User and Review models. Ensure that these changes are reflected in the application code where these fields are used.

  • 49-55: The Session model remains largely unchanged, but the user field has been renamed to User to match the naming convention of other relation fields. This change should not affect the functionality, but make sure to update any references to this field in the codebase.

  • 57-74: The User model has been updated. The accounts and sessions fields have been renamed to Account and Session respectively. The hacker and reviewer fields have been replaced with Review_Review_hackerIdToUser and Review_Review_reviewerIdToUser respectively. These changes reflect the new relations between the User and other models. Ensure that these changes are reflected in the application code where these fields are used.

  • 76-81: The VerificationToken model remains unchanged. No action needed.

  • 99-101: The Role enum remains unchanged. No action needed.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1eb5e74 and 465d6bf.
Files ignored due to filter (1)
  • prisma/migrations/migration_lock.toml
Files selected for processing (1)
  • prisma/migrations/0_init/migration.sql (1 hunks)
Files skipped from review due to trivial changes (1)
  • prisma/migrations/0_init/migration.sql

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 465d6bf and a1cf30f.
Files selected for processing (1)
  • prisma/schema.prisma (3 hunks)
Additional comments: 1
prisma/schema.prisma (1)
  • 6-12: The database provider has been changed from "postgresql" to "cockroachdb". Ensure that the database connection string in the environment variables is updated accordingly and that the CockroachDB instance is properly set up.

Comment on lines 21 to 36
type String
provider String
providerAccountId String
refresh_token String? @db.Text
refresh_token String? //@db.Text
refresh_token_expires_in Int?
access_token String? @db.Text
access_token String? //@db.Text
expires_at Int?
ext_expires_in Int?
oauth_token_secret String? @db.Text
oauth_token String? @db.Text
oauth_token_secret String? //@db.Text
oauth_token String? //@db.Text
token_type String?
scope String?
id_token String? @db.Text
id_token String? //@db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

Copy link
Contributor

Choose a reason for hiding this comment

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

The refresh_token, access_token, oauth_token_secret, oauth_token, and id_token fields in the Account model have been commented out. If these fields are not used, consider removing them entirely. If they are needed in the future, they can be added back. Leaving commented-out code can lead to confusion and clutter.

Comment on lines 53 to 59
image String?
accounts Account[]
sessions Session[]
typeform_response_id String? @db.Text
typeform_response_id String? //@db.Text
role Role[] @default([HACKER])
hacker Review[] @relation("hacker")
reviewer Review[] @relation("reviewer")
Copy link
Contributor

Choose a reason for hiding this comment

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

The typeform_response_id field in the User model has been commented out. Similar to the previous comment, consider removing this field if it's not used. If it's needed in the future, it can be added back.

@arian81 arian81 force-pushed the arian/tech-47-migrate-to-prisma-v5 branch from a1cf30f to e3cd7e3 Compare November 4, 2023 03:54
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a1cf30f and ad25e6d.
Files ignored due to filter (2)
  • package-lock.json
  • package.json
Files selected for processing (5)
  • src/pages/checkin.tsx (1 hunks)
  • src/pages/dashboard.tsx (1 hunks)
  • src/pages/me.tsx (1 hunks)
  • src/pages/scanner.tsx (6 hunks)
  • src/pages/welcome.tsx (1 hunks)
Files skipped from review due to trivial changes (4)
  • src/pages/checkin.tsx
  • src/pages/dashboard.tsx
  • src/pages/me.tsx
  • src/pages/welcome.tsx
Additional comments: 5
src/pages/scanner.tsx (5)
  • 22-26: The ssr property is set to false for the ConstantQRReaderDynamic component. This means that the component will not be server-side rendered. This is typically done for components that rely on browser-specific APIs. Ensure that this is the intended behavior.

  • 63-67: The dependency array of the useEffect hook in the FoodManagerView component is updated to include utils. This means that the effect will re-run whenever utils changes. Ensure that this is the intended behavior and that utils changes infrequently to avoid unnecessary re-renders.

  • 166-172: The dependency array of the useEffect hook in the SponsorView component is updated to include qrDefer. This means that the effect will re-run whenever qrDefer changes. Ensure that this is the intended behavior and that qrDefer changes infrequently to avoid unnecessary re-renders.

  • 268-274: The dependency array of the useEffect hook in the HackerView component is updated to include qrDefer. This means that the effect will re-run whenever qrDefer changes. Ensure that this is the intended behavior and that qrDefer changes infrequently to avoid unnecessary re-renders.

  • 308-314: The text "High Schooler" is replaced with "High Schooler" in the socialInfo?.currentLevel value. This seems to be a no-op change. If the intention was to change the text, please verify that the correct text was used.

Comment on lines 605 to 609
export const getServerSideProps = async (
context: GetServerSidePropsContext
context: GetServerSidePropsContext,
) => {
const session = await getServerAuthSession(context);

Copy link
Contributor

Choose a reason for hiding this comment

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

The getServerSideProps function now includes a comma after the context parameter. This is a syntax error and will cause the code to fail. If the intention was to add another parameter, please add it.

-  context: GetServerSidePropsContext,
+  context: GetServerSidePropsContext

Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Make sure it correctly replaces the highlighted code, has no missing lines and indentaion issues.

Suggested change
export const getServerSideProps = async (
context: GetServerSidePropsContext
context: GetServerSidePropsContext,
) => {
const session = await getServerAuthSession(context);
export const getServerSideProps = async (
context: GetServerSidePropsContext
) => {
const session = await getServerAuthSession(context);

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ad25e6d and 082cac2.
Files selected for processing (1)
  • .eslintrc.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • .eslintrc.json

@Krish120003
Copy link
Member

This branch is quite broken and outdated. Instead of running a script, packages need to be upgraded manually while making sure the application builds. Closing for now.

@Krish120003 Krish120003 closed this Nov 4, 2023
@arian81 arian81 deleted the arian/tech-47-migrate-to-prisma-v5 branch November 17, 2023 20:34
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