Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ CACHE_DRIVER=inMemory
REDIS_PORT= 6379
REDIS_HOST='localhost'

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
# em prod: https://api.vcnafacul.com.br/user/auth/google/callback
GOOGLE_CALLBACK_URL=http://localhost:3333/user/auth/google/callback
CLIENT_URL=http://localhost:5173
# Queue: 'memory' (in-memory, dev/homol) | 'redis' (prod)
QUEUE_DRIVER=memory

Expand Down
93 changes: 78 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@nestjs/typeorm": "^10.0.0",
"@react-email/components": "0.0.27",
"@react-email/tailwind": "1.0.1",
"@types/passport-google-oauth20": "^2.0.17",
"@types/qrcode": "^1.5.6",
"axios": "^1.5.0",
"basic-ftp": "^5.0.3",
Expand All @@ -68,6 +69,7 @@
"nodemailer-express-handlebars": "^6.1.2",
"openai": "^6.32.0",
"passport": "^0.7.0",
"passport-google-oauth20": "^2.0.0",
"passport-jwt": "^4.0.1",
"pdfmake": "^0.2.20",
"pg": "^8.11.3",
Expand Down
88 changes: 88 additions & 0 deletions src/db/migrations/1778250000000-google-social-login.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class GoogleSocialLogin1778250000000 implements MigrationInterface {
name = 'GoogleSocialLogin1778250000000';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`password\` varchar(255) NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`phone\` varchar(255) NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`gender\` int NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`birthday\` datetime NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`state\` varchar(255) NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`city\` varchar(255) NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` ADD \`google_id\` varchar(255) NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` ADD UNIQUE INDEX \`IDX_users_google_id\` (\`google_id\`)`,
);
await queryRunner.query(
`ALTER TABLE \`users\` ADD \`profile_complete\` tinyint NULL`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE \`users\` DROP COLUMN \`profile_complete\``,
);
await queryRunner.query(
`ALTER TABLE \`users\` DROP INDEX \`IDX_users_google_id\``,
);
// Remover usuários criados via Google antes de restaurar NOT NULL,
// pois esses registros possuem colunas obrigatórias nulas.
await queryRunner.query(
`DELETE FROM \`users\` WHERE \`google_id\` IS NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` DROP COLUMN \`google_id\``,
);
await queryRunner.query(
`UPDATE \`users\` SET \`city\` = '' WHERE \`city\` IS NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`city\` varchar(255) NOT NULL`,
);
await queryRunner.query(
`UPDATE \`users\` SET \`state\` = '' WHERE \`state\` IS NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`state\` varchar(255) NOT NULL`,
);
await queryRunner.query(
`UPDATE \`users\` SET \`birthday\` = '1970-01-01' WHERE \`birthday\` IS NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`birthday\` datetime NOT NULL`,
);
await queryRunner.query(
`UPDATE \`users\` SET \`gender\` = 0 WHERE \`gender\` IS NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`gender\` int NOT NULL`,
);
await queryRunner.query(
`UPDATE \`users\` SET \`phone\` = '' WHERE \`phone\` IS NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`phone\` varchar(255) NOT NULL`,
);
await queryRunner.query(
`UPDATE \`users\` SET \`password\` = '' WHERE \`password\` IS NULL`,
);
await queryRunner.query(
`ALTER TABLE \`users\` MODIFY \`password\` varchar(255) NOT NULL`,
Comment thread
RafaelFantinel marked this conversation as resolved.
);
}
}
Loading
Loading