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

Postgres migrations are inconsistent on alternate schema #3325

Closed
2 tasks
Tomsons opened this issue May 19, 2022 · 3 comments · Fixed by #3356
Closed
2 tasks

Postgres migrations are inconsistent on alternate schema #3325

Tomsons opened this issue May 19, 2022 · 3 comments · Fixed by #3356

Comments

@Tomsons
Copy link

Tomsons commented May 19, 2022

Describe the bug
The current migrations are inconsistent, which means that there is no way to start a new n8n instance on a clean Postgres DB with an alternate schema. Following your docker-compose example produces the following output:

Initializing n8n process
UserSettings were generated and saved to: /root/.n8n/config
query is slow: SELECT * FROM "n8n"."migrations" "migrations"  ORDER BY "id" DESC
execution time: 3234
There was an error initializing DB: "relation "credentials_entity" does not exist"

Stopping n8n...

To Reproduce
Steps to reproduce the behavior:

  1. Follow the docker-compose example for Postgres by using a schema other than public

Expected behavior
All migrations should run as expected and the application should startup

Environment (please complete the following information):

  • OS: [e.g. Ubuntu Linux 18.04]
  • n8n Version: docker digest 403a10ae480e18502eb80ca6490a5ba54555251911ff91c1766dd6c30987fdaa
  • Node.js Version: the container's
  • Database system: Postgres
  • Operation mode: own

Recommendations

  • Provide an extra cli command to run only the migrations
  • Introduce an extra CI check to ensure the all migrations for all db engines are working as expected
@Tomsons Tomsons changed the title Postgres migrations are inconsistent Postgres migrations are inconsistent on alternate schema May 20, 2022
@ivov
Copy link
Contributor

ivov commented May 20, 2022

Thank you for your report.

Busy with other tasks at the moment, but from a quick look it seems to be the whitespace before the tablename:

`INSERT INTO ${tablePrefix}shared_credentials ("createdAt", "updatedAt", "roleId", "userId", "credentialsId") SELECT NOW(), NOW(), '${credentialOwnerRole[0].insertId}', '${ownerUserId}', "id" FROM ${tablePrefix} credentials_entity`,

@janober
Copy link
Member

janober commented May 30, 2022

Got fixed with #3356 and will be released with the next version.

@janober janober added the Upcoming Release Will be part of the upcoming release label May 30, 2022
@janober
Copy link
Member

janober commented May 30, 2022

Fix got released with n8n@0.179.0

@janober janober removed the Upcoming Release Will be part of the upcoming release label May 30, 2022
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 a pull request may close this issue.

3 participants