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

Migrating to version 3 #781

Open
poeti8 opened this issue Jan 9, 2025 · 10 comments
Open

Migrating to version 3 #781

poeti8 opened this issue Jan 9, 2025 · 10 comments

Comments

@poeti8
Copy link
Member

poeti8 commented Jan 9, 2025

Version 3 has just been released. If you have troubles migrating to the new version, please write them here.

Read the migration guide on the version 3 release note:
https://github.com/thedevs-network/kutt/releases/tag/v3.0.0

@gramakri
Copy link

gramakri commented Jan 9, 2025

There is a postgres migration issue:

migration file "20241223103044_visits_user_id.js" failed
13:19:52 - migration failed with error: select count("'*'") as "count" from "visits" - column "'*'" does not exist
13:19:52 - select count("'*'") as "count" from "visits" - column "'*'" does not exist
13:19:52 - error: select count("'*'") as "count" from "visits" - column "'*'" does not exist
13:19:52 - at Parser.parseErrorMessage (/app/code/node_modules/pg-protocol/dist/parser.js:283:98)
13:19:52 - at Parser.handlePacket (/app/code/node_modules/pg-protocol/dist/parser.js:122:29)
13:19:52 - at Parser.parse (/app/code/node_modules/pg-protocol/dist/parser.js:35:38)
13:19:52 - at Socket.<anonymous> (/app/code/node_modules/pg-protocol/dist/index.js:11:42)
13:19:52 - at Socket.emit (node:events:524:28)
13:19:52 - at addChunk (node:internal/streams/readable:561:12)
13:19:52 - at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
13:19:52 - at Readable.push (node:internal/streams/readable:392:5)
13:19:52 - at TCP.onStreamRead (node:internal/stream_base_commons:189:23)

@poeti8
Copy link
Member Author

poeti8 commented Jan 9, 2025

@gramakri Fixing it right now. See #779

@gramakri
Copy link

gramakri commented Jan 9, 2025

@poeti8 this fixes it

  const [{ count }] = await knex("visits").count("* as count");
  if (count === '0') return;

@gramakri
Copy link

gramakri commented Jan 9, 2025

Per upstream docs maybe const [{ count }] = await knex("visits").select(knex.raw("count(*) as count")); is more portable but I don't know knex much. From https://github.com/knex/knex/blob/b6507a7129d2b9fafebf5f831494431e64c6a8a0/docs/src/guide/raw.md?plain=1#L11 . I have tested this and this also works on postgres.

@gramakri
Copy link

gramakri commented Jan 9, 2025

@poeti8 the if (count === '0') return; line is also needed for the case where count is 0 . Otherwise, it crashes later when accessing id. But maybe this doesn't happen much other than my testing installation where nothing was visited :-)

@poeti8
Copy link
Member Author

poeti8 commented Jan 9, 2025

@gramakri Yes I just noticed that, I was fixing it now.

@waclaw66
Copy link

waclaw66 commented Jan 9, 2025

There was no error after upgrade to v3 of Docker image, however database migration did not take place. There are still only those migrations...
obrazek

3.0.1

How to force db migration? What's the trigger?

@poeti8
Copy link
Member Author

poeti8 commented Jan 9, 2025

@waclaw66 make sure DB_ environment variables are set correctly. I guess the migrations ran for the default database which is SQLite, or maybe another database for your Postgres user.

@waclaw66
Copy link

waclaw66 commented Jan 9, 2025

@poeti8 Yes, I forgot to add DB_CLIENT env variable, then sqlite db was created. When I added that env with pg value, migrations were not processed within postgres. All links are now visible again, however migrations stucked. How to push the migration?

@waclaw66
Copy link

waclaw66 commented Jan 9, 2025

I was able to run knex migrations within docker container using command npx knex migrate:latest, now migrations seems to be done.

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

No branches or pull requests

3 participants