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

add helpUsImprove field to the backend #615

Merged

Conversation

kdachev97
Copy link
Contributor

This ticket is related to the frontend ticket: feature/add-tickbox-to-registration-field

Added the helpUsImprove field to the schema.prisma and register.dto.ts files as requested

Copy link

github-actions bot commented Mar 17, 2024

✅ Tests will run for this PR. Once they succeed it can be merged.

Copy link
Member

@sashko9807 sashko9807 left a comment

Choose a reason for hiding this comment

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

Great job!
When changing the prisma schema in order for those changes to be implemented in the database we need to run yarn prisma migrate dev. This command will automatically generate the SQL query to add the help_us_improve field to the persons table, as well as auto-generating the changes for the Prisma Client.

Once yarn prisma migrate dev is finished, execute yarn format, which will run prettier on all generated.

So in summary:

  1. Run yarn prisma migrate dev to generate the SQL query which updates the person table
  2. Run yarn format - to prettify the generated Prisma clients.
  3. Commit the changes.

If you have further questions regarding the requested changes, feel free to contact me.

schema.prisma Outdated
@@ -40,6 +40,7 @@ model Person {
updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamptz(6)
// Receive marketing notifications
newsletter Boolean? @default(false)
helpUsImporve Boolean? @default(false)
Copy link
Member

Choose a reason for hiding this comment

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

There is a typo. Change to helpUsImprove
We use snake_case for referencing a field via raw SQL query. Would you please add @Map("help_us_improve") at the end of this line.
Example:

helpUsImporve      Boolean?            @default(false) @map("help_us_improve")

@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Mar 18, 2024
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Mar 18, 2024
schema.prisma Outdated
@@ -40,6 +40,7 @@ model Person {
updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamptz(6)
// Receive marketing notifications
newsletter Boolean? @default(false)
helpUsImporve Boolean? @default(false)
Copy link
Member

@sashko9807 sashko9807 Mar 18, 2024

Choose a reason for hiding this comment

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

Please fix the typo, as well as add @map("help_us_improve"), as we use snake_case for referencing db fields directly

helpUsImporve      Boolean?            @default(false) @map("help_us_improve")

Then re-execute the yarn prisma migrate dev and yarn format

Edit: Linter is failing due to missing field field in personMock.
After you fix the above typo, please add helpUsImprove field to the personMock.ts

@kdachev97
Copy link
Contributor Author

kdachev97 commented Mar 18, 2024 via email

@sashko9807
Copy link
Member

sashko9807 commented Mar 18, 2024

Should I delete the previous migration?

It would be best if you can. As it will keep the migration folder more tidier.

Please fix the typo, as well as add @map("help_us_improve"), as we use snake_case for referencing db fields directly.
Example:

helpUsImprove      Boolean?            @default(false) @map("help_us_improve")

Then re-execute the yarn prisma migrate dev and yarn format
Once the commands from above are executed, please also fix the failing API test job due to missing helpUsImprove field in personMock.ts, e.g. just add helpUsImprove at the end of the object.

@sashko9807
Copy link
Member

Hmm. apparently I forgot to tell you to add the following line:

helpUsImprove: registerDto.helpUsImprove ? registerDto.helpUsImprove : false

to the person.upsert method here. Do yo mind adding it? Sorry for that.

@kdachev97
Copy link
Contributor Author

kdachev97 commented Mar 18, 2024 via email

@sashko9807
Copy link
Member

Do I need to run new migrations or is it just that?

Just that change. Everything regarding the migration is OK.

@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Mar 18, 2024
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Mar 18, 2024
@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Mar 18, 2024
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Mar 18, 2024
@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Mar 18, 2024
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Mar 18, 2024
@slavcho slavcho merged commit 4c5dee2 into podkrepi-bg:master Mar 19, 2024
9 of 10 checks passed
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.

3 participants