[GH-ISSUE #4157] [bug]: Database not updated with Version 2024.6.0 (Hoppscotch not usable) #1495

Closed
opened 2026-03-16 20:34:24 +03:00 by kerem · 8 comments
Owner

Originally created by @pthoelken on GitHub (Jul 1, 2024).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4157

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

After upgrade to HS 2024.6.0 I'm not able to login. In the log appears these kind of errors. I'm coming from version 2024.3.4 to the latest.

hoppscotchdb      | 2024-07-01 08:18:07.591 CEST [40] ERROR:  column User.lastLoggedOn does not exist at character 249
hoppscotchdb      | 2024-07-01 08:18:07.591 CEST [40] STATEMENT:  SELECT "public"."User"."uid", "public"."User"."displayName", "public"."User"."email", "public"."User"."photoURL", "public"."User"."isAdmin", "public"."User"."refreshToken", "public"."User"."currentRESTSession", "public"."User"."currentGQLSession", "public"."User"."lastLoggedOn", "public"."User"."lastActiveOn", "public"."User"."createdOn" FROM "public"."User" WHERE "public"."User"."email" ILIKE $1 LIMIT $2 OFFSET $3
hoppscotch-aio    | Backend Server | [Nest] 70  - 07/01/2024, 6:18:07 AM   ERROR[ExceptionsHandler]
hoppscotch-aio    | Backend Server | Invalid `this.prisma.user.findFirst()` invocation in
hoppscotch-aio    | Backend Server | /usr/src/app/packages/hoppscotch-backend/dist/user/user.service.js:46:45
hoppscotch-aio    | Backend Server |
hoppscotch-aio    | Backend Server |   43             : null });
hoppscotch-aio    | Backend Server |   44 }
hoppscotch-aio    | Backend Server |   45 async findUserByEmail(email) {
hoppscotch-aio    | Backend Server | → 46     const user = await this.prisma.user.findFirst(
hoppscotch-aio    | Backend Server | The column `User.lastLoggedOn` does not exist in the current database.
hoppscotch-aio    | Backend Server | PrismaClientKnownRequestError:
hoppscotch-aio    | Backend Server | Invalid `this.prisma.user.findFirst()` invocation in
hoppscotch-aio    | Backend Server | /usr/src/app/packages/hoppscotch-backend/dist/user/user.service.js:46:45
hoppscotch-aio    | Backend Server |
hoppscotch-aio    | Backend Server |   43             : null });
hoppscotch-aio    | Backend Server |   44 }
hoppscotch-aio    | Backend Server |   45 async findUserByEmail(email) {
hoppscotch-aio    | Backend Server | → 46     const user = await this.prisma.user.findFirst(
hoppscotch-aio    | Backend Server | The column `User.lastLoggedOn` does not exist in the current database.
hoppscotch-aio    | Backend Server |     at si.handleRequestError (/usr/src/app/node_modules/.pnpm/@prisma+client@5.8.1_prisma@5.8.1/node_modules/@prisma/client/runtime/library.js:125:6817)
hoppscotch-aio    | Backend Server |     at si.handleAndLogRequestError (/usr/src/app/node_modules/.pnpm/@prisma+client@5.8.1_prisma@5.8.1/node_modules/@prisma/client/runtime/library.js:125:6151)
hoppscotch-aio    | Backend Server |     at si.request (/usr/src/app/node_modules/.pnpm/@prisma+client@5.8.1_prisma@5.8.1/node_modules/@prisma/client/runtime/library.js:125:5859)
hoppscotch-aio    | Backend Server |     at async l (/usr/src/app/node_modules/.pnpm/@prisma+client@5.8.1_prisma@5.8.1/node_modules/@prisma/client/runtime/library.js:130:9805)
hoppscotch-aio    | Backend Server |     at async UserService.findUserByEmail (/usr/src/app/packages/hoppscotch-backend/dist/user/user.service.js:46:22)
hoppscotch-aio    | Backend Server |     at async MicrosoftStrategy.validate (/usr/src/app/packages/hoppscotch-backend/dist/auth/strategies/microsoft.strategy.js:36:22)
hoppscotch-aio    | Backend Server |     at async MicrosoftStrategy.callback [as _verify] (/usr/src/app/node_modules/.pnpm/@nestjs+passport@10.0.2_@nestjs+common@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0__passport@0.6.0/node_modules/@nestjs/passport/dist/passport/passport.strategy.js:11:44)

Steps to reproduce

update to latest Version

Environment

Release

Version

Self-hosted

Originally created by @pthoelken on GitHub (Jul 1, 2024). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4157 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior After upgrade to HS 2024.6.0 I'm not able to login. In the log appears these kind of errors. I'm coming from version 2024.3.4 to the latest. ``` hoppscotchdb | 2024-07-01 08:18:07.591 CEST [40] ERROR: column User.lastLoggedOn does not exist at character 249 hoppscotchdb | 2024-07-01 08:18:07.591 CEST [40] STATEMENT: SELECT "public"."User"."uid", "public"."User"."displayName", "public"."User"."email", "public"."User"."photoURL", "public"."User"."isAdmin", "public"."User"."refreshToken", "public"."User"."currentRESTSession", "public"."User"."currentGQLSession", "public"."User"."lastLoggedOn", "public"."User"."lastActiveOn", "public"."User"."createdOn" FROM "public"."User" WHERE "public"."User"."email" ILIKE $1 LIMIT $2 OFFSET $3 hoppscotch-aio | Backend Server | [Nest] 70 - 07/01/2024, 6:18:07 AM ERROR[ExceptionsHandler] hoppscotch-aio | Backend Server | Invalid `this.prisma.user.findFirst()` invocation in hoppscotch-aio | Backend Server | /usr/src/app/packages/hoppscotch-backend/dist/user/user.service.js:46:45 hoppscotch-aio | Backend Server | hoppscotch-aio | Backend Server | 43 : null }); hoppscotch-aio | Backend Server | 44 } hoppscotch-aio | Backend Server | 45 async findUserByEmail(email) { hoppscotch-aio | Backend Server | → 46 const user = await this.prisma.user.findFirst( hoppscotch-aio | Backend Server | The column `User.lastLoggedOn` does not exist in the current database. hoppscotch-aio | Backend Server | PrismaClientKnownRequestError: hoppscotch-aio | Backend Server | Invalid `this.prisma.user.findFirst()` invocation in hoppscotch-aio | Backend Server | /usr/src/app/packages/hoppscotch-backend/dist/user/user.service.js:46:45 hoppscotch-aio | Backend Server | hoppscotch-aio | Backend Server | 43 : null }); hoppscotch-aio | Backend Server | 44 } hoppscotch-aio | Backend Server | 45 async findUserByEmail(email) { hoppscotch-aio | Backend Server | → 46 const user = await this.prisma.user.findFirst( hoppscotch-aio | Backend Server | The column `User.lastLoggedOn` does not exist in the current database. hoppscotch-aio | Backend Server | at si.handleRequestError (/usr/src/app/node_modules/.pnpm/@prisma+client@5.8.1_prisma@5.8.1/node_modules/@prisma/client/runtime/library.js:125:6817) hoppscotch-aio | Backend Server | at si.handleAndLogRequestError (/usr/src/app/node_modules/.pnpm/@prisma+client@5.8.1_prisma@5.8.1/node_modules/@prisma/client/runtime/library.js:125:6151) hoppscotch-aio | Backend Server | at si.request (/usr/src/app/node_modules/.pnpm/@prisma+client@5.8.1_prisma@5.8.1/node_modules/@prisma/client/runtime/library.js:125:5859) hoppscotch-aio | Backend Server | at async l (/usr/src/app/node_modules/.pnpm/@prisma+client@5.8.1_prisma@5.8.1/node_modules/@prisma/client/runtime/library.js:130:9805) hoppscotch-aio | Backend Server | at async UserService.findUserByEmail (/usr/src/app/packages/hoppscotch-backend/dist/user/user.service.js:46:22) hoppscotch-aio | Backend Server | at async MicrosoftStrategy.validate (/usr/src/app/packages/hoppscotch-backend/dist/auth/strategies/microsoft.strategy.js:36:22) hoppscotch-aio | Backend Server | at async MicrosoftStrategy.callback [as _verify] (/usr/src/app/node_modules/.pnpm/@nestjs+passport@10.0.2_@nestjs+common@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0__passport@0.6.0/node_modules/@nestjs/passport/dist/passport/passport.strategy.js:11:44) ``` ### Steps to reproduce update to latest Version ### Environment Release ### Version Self-hosted
kerem 2026-03-16 20:34:24 +03:00
Author
Owner

@balub commented on GitHub (Jul 1, 2024):

Hey @pthoelken, can you run the migration and try again ?

<!-- gh-comment-id:2199345506 --> @balub commented on GitHub (Jul 1, 2024): Hey @pthoelken, can you run the migration and try again ?
Author
Owner

@pthoelken commented on GitHub (Jul 1, 2024):

@balub you mean these instructions here? https://docs.hoppscotch.io/documentation/self-host/community-edition/install-and-build#migrations

I'll test it tomorrow morning and come back here.

<!-- gh-comment-id:2199346989 --> @pthoelken commented on GitHub (Jul 1, 2024): @balub you mean these instructions here? https://docs.hoppscotch.io/documentation/self-host/community-edition/install-and-build#migrations I'll test it tomorrow morning and come back here.
Author
Owner

@Brainpitcher commented on GitHub (Jul 1, 2024):

i made it already and i got this

`/usr/src/app/packages/hoppscotch-backend # pnpx prisma migrate deploy
Packages: +6
++++++
Progress: resolved 6, reused 0, downloaded 6, added 6, done
.cache/pnpm/dlx/32qs76zfpdzhrg4l3y6ui3zucu/1906d351bf9-7a/node_modules/.pnpm/@prisma+engines@5.16.1/node_modules/@prisma/engines: Running postinstall script, done in 4.2s
.cache/pnpm/dlx/32qs76zfpdzhrg4l3y6ui3zucu/1906d351bf9-7a/node_modules/.pnpm/prisma@5.16.1/node_modules/prisma: Running preinstall script, done in 75ms
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "hoppscotch", schema "public" at "c-hqnulgjid1l6.rw.mdb.cloud.net:6432"

8 migrations found in prisma/migrations

Applying migration 20240226053141_full_text_search_additions
Error: P3018

A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve

Migration name: 20240226053141_full_text_search_additions

Database error code: 42501

Database error:
ERROR: permission denied to create extension "pg_trgm"
HINT: Must be superuser to create this extension.

DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42501), message: "permission denied to create extension "pg_trgm"", detail: None, hint: Some("Must be superuser to create this extension."), position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("extension.c"), line: Some(916), routine: Some("execute_extension_script") }`

<!-- gh-comment-id:2199443124 --> @Brainpitcher commented on GitHub (Jul 1, 2024): i made it already and i got this `/usr/src/app/packages/hoppscotch-backend # pnpx prisma migrate deploy Packages: +6 ++++++ Progress: resolved 6, reused 0, downloaded 6, added 6, done .cache/pnpm/dlx/32qs76zfpdzhrg4l3y6ui3zucu/1906d351bf9-7a/node_modules/.pnpm/@prisma+engines@5.16.1/node_modules/@prisma/engines: Running postinstall script, done in 4.2s .cache/pnpm/dlx/32qs76zfpdzhrg4l3y6ui3zucu/1906d351bf9-7a/node_modules/.pnpm/prisma@5.16.1/node_modules/prisma: Running preinstall script, done in 75ms Prisma schema loaded from prisma/schema.prisma Datasource "db": PostgreSQL database "hoppscotch", schema "public" at "c-hqnulgjid1l6.rw.mdb.cloud.net:6432" 8 migrations found in prisma/migrations Applying migration `20240226053141_full_text_search_additions` Error: P3018 A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve Migration name: 20240226053141_full_text_search_additions Database error code: 42501 Database error: ERROR: permission denied to create extension "pg_trgm" HINT: Must be superuser to create this extension. DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42501), message: "permission denied to create extension \"pg_trgm\"", detail: None, hint: Some("Must be superuser to create this extension."), position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("extension.c"), line: Some(916), routine: Some("execute_extension_script") }`
Author
Owner

@Brainpitcher commented on GitHub (Jul 1, 2024):

in addition
I encountered an issue while deploying the migration 20240226053141_full_text_search_additions. The migration fails with the following error:

ERROR: permission denied to create extension "pg_trgm"
HINT: Must be superuser to create this extension.

This error indicates that the migration attempts to create the pg_trgm extension, which requires superuser privileges. However, not all database users have these privileges, and this led to the migration failure.

Suggestions for Improvement
Communication: Please inform all team members about the requirement to enable certain extensions like pg_trgm before running the migration. This can be communicated through the migration documentation or comments within the migration file.

Pre-migration Steps: Consider adding pre-migration steps or a separate script to ensure necessary extensions are enabled. This script can be run by a superuser before the main migration is applied.

Alternative Approaches: If feasible, modify the migration to avoid requiring superuser privileges, such as using database functions that do not depend on the pg_trgm extension.

now everything works fine

<!-- gh-comment-id:2199500339 --> @Brainpitcher commented on GitHub (Jul 1, 2024): in addition I encountered an issue while deploying the migration 20240226053141_full_text_search_additions. The migration fails with the following error: ``` ERROR: permission denied to create extension "pg_trgm" HINT: Must be superuser to create this extension. ``` This error indicates that the migration attempts to create the pg_trgm extension, which requires superuser privileges. However, not all database users have these privileges, and this led to the migration failure. Suggestions for Improvement Communication: Please inform all team members about the requirement to enable certain extensions like pg_trgm before running the migration. This can be communicated through the migration documentation or comments within the migration file. Pre-migration Steps: Consider adding pre-migration steps or a separate script to ensure necessary extensions are enabled. This script can be run by a superuser before the main migration is applied. Alternative Approaches: If feasible, modify the migration to avoid requiring superuser privileges, such as using database functions that do not depend on the pg_trgm extension. now everything works fine
Author
Owner

@pthoelken commented on GitHub (Jul 2, 2024):

@balub can you confirm the latest issues in this thread? It's possible for you to give exact informations and steps what to do after the new images are pulled?

<!-- gh-comment-id:2201978932 --> @pthoelken commented on GitHub (Jul 2, 2024): @balub can you confirm the latest issues in this thread? It's possible for you to give exact informations and steps what to do after the new images are pulled?
Author
Owner

@balub commented on GitHub (Jul 2, 2024):

@pthoelken, the issue is that the user needs the superuser privileges to create the extension. If possible you can try creating a new user with the superuser privileges or upgrade an already existing one to a superuser using ALTER ROLE <user_name> SUPERUSER; command and then try running the migration again.

<!-- gh-comment-id:2202235564 --> @balub commented on GitHub (Jul 2, 2024): @pthoelken, the issue is that the user needs the superuser privileges to create the extension. If possible you can try creating a new user with the superuser privileges or upgrade an already existing one to a superuser using `ALTER ROLE <user_name> SUPERUSER;` command and then try running the migration again.
Author
Owner

@Brainpitcher commented on GitHub (Jul 2, 2024):

@pthoelken, the issue is that the user needs the superuser privileges to create the extension. If possible you can try creating a new user with the superuser privileges or upgrade an already existing one to a superuser using ALTER ROLE <user_name> SUPERUSER; command and then try running the migration again.

i think it would be nice if you just add the need of a "pg_trgm" extension as the necessity

<!-- gh-comment-id:2203057599 --> @Brainpitcher commented on GitHub (Jul 2, 2024): > @pthoelken, the issue is that the user needs the superuser privileges to create the extension. If possible you can try creating a new user with the superuser privileges or upgrade an already existing one to a superuser using `ALTER ROLE <user_name> SUPERUSER;` command and then try running the migration again. i think it would be nice if you just add the need of a "pg_trgm" extension as the necessity
Author
Owner

@pthoelken commented on GitHub (Jul 3, 2024):

https://docs.hoppscotch.io/documentation/self-host/community-edition/install-and-build#migrations

works pretty charm. Thanks for your assistance in this case.

<!-- gh-comment-id:2205148257 --> @pthoelken commented on GitHub (Jul 3, 2024): https://docs.hoppscotch.io/documentation/self-host/community-edition/install-and-build#migrations works pretty charm. Thanks for your assistance in this case.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1495
No description provided.