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
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/api/src/auth/dto/register.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export class RegisterDto {
@IsBoolean()
public readonly newsletter?: boolean

@ApiProperty()
@Expose()
@IsOptional()
@IsBoolean()
public readonly helpUsImprove?: boolean

@ValidateIf((o) => o.type === ProfileType.CORPORATE)
@Expose()
@IsString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class CreatePersonDto {
email?: string
phone?: string
newsletter?: boolean
helpUsImporve?: boolean
address?: string
birthday?: Date
emailConfirmed?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class UpdatePersonDto {
email?: string
phone?: string
newsletter?: boolean
helpUsImporve?: boolean
address?: string
birthday?: Date
emailConfirmed?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class Person {
createdAt: Date
updatedAt: Date | null
newsletter: boolean | null
helpUsImporve: boolean | null
address: string | null
birthday: Date | null
emailConfirmed: boolean | null
Expand Down
2 changes: 2 additions & 0 deletions migrations/20240318115029_help_us_improve_field/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "people" ADD COLUMN "helpUsImporve" BOOLEAN DEFAULT false;
1 change: 1 addition & 0 deletions podkrepi.dbml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Table people {
createdAt DateTime [default: `now()`, not null]
updatedAt DateTime
newsletter Boolean [default: false]
helpUsImporve Boolean [default: false]
address String
birthday DateTime
emailConfirmed Boolean [default: false]
Expand Down
1 change: 1 addition & 0 deletions schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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")

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

address String? @db.VarChar(100)
birthday DateTime? @db.Timestamptz(6)
emailConfirmed Boolean? @default(false) @map("email_confirmed")
Expand Down
Loading