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

Error executing migration on latest image #1860

Closed
johnnyasantoss opened this issue Mar 11, 2024 · 4 comments
Closed

Error executing migration on latest image #1860

johnnyasantoss opened this issue Mar 11, 2024 · 4 comments

Comments

@johnnyasantoss
Copy link

I'm trying to self host the server using the latest image from ghcr.io (latest, 1464cb6 - on x64), and it fails with a migration error on starting with a clean db.

atuin-1  | 2024-03-11T14:54:15.000208Z DEBUG sqlx::query: summary="SELECT current_database()" db.statement="" rows_affected=0 rows_returned=1 elapsed=311.904µs
atuin-1  | 2024-03-11T14:54:15.000465Z DEBUG sqlx::query: summary="SELECT pg_advisory_lock($1)" db.statement="" rows_affected=1 rows_returned=1 elapsed=219.354µs
atuin-1  | 2024-03-11T14:54:15.000639Z  INFO sqlx::postgres::notice: relation "_sqlx_migrations" already exists, skipping
atuin-1  | 2024-03-11T14:54:15.001080Z DEBUG sqlx::query: summary="CREATE TABLE IF NOT …" db.statement="\n\nCREATE TABLE IF NOT EXISTS _sqlx_migrations (\n  version BIGINT PRIMARY KEY,\n  description TEXT NOT NULL,\n  installed_on TIMESTAMPTZ NOT NULL DEFAULT now(),\n  success BOOLEAN NOT NULL,\n  checksum BYTEA NOT NULL,\n  execution_time BIGINT NOT NULL\n);\n" rows_affected=0 rows_returned=0 elapsed=270.539µs
atuin-1  | 2024-03-11T14:54:15.002206Z DEBUG sqlx::query: summary="SELECT version FROM _sqlx_migrations …" db.statement="\n\nSELECT\n  version\nFROM\n  _sqlx_migrations\nWHERE\n  success = false\nORDER BY\n  version\nLIMIT\n  1\n" rows_affected=0 rows_returned=0 elapsed=979.365µs
atuin-1  | 2024-03-11T14:54:15.002643Z DEBUG sqlx::query: summary="SELECT version, checksum FROM …" db.statement="\n\nSELECT\n  version,\n  checksum\nFROM\n  _sqlx_migrations\nORDER BY\n  version\n" rows_affected=11 rows_returned=11 elapsed=309.886µs
atuin-1  | 2024-03-11T14:54:15.003438Z DEBUG sqlx::query: summary="-- We do not …" db.statement="\n\n-- We do not need to run the trigger on deletes, as the only time we are deleting history is when the user\n-- has already been deleted\n-- This actually slows down deleting all the history a good bit!\ncreate\nor replace function user_history_count() returns trigger as $func$\nbegin\nif (TG_OP = 'INSERT') then\nupdate\n  total_history_count_user\nset\n  total = total + 1\nwhere\n  user_id = new.user_id;\nif not found then\ninsert into\n  total_history_count_user(user_id, total)\nvalues\n  (\n    new.user_id,\n    (\n      select\n        count(1)\n      from\n        history\n      where\n        user_id = new.user_id\n    )\n  );\nend if;\nend if;\nreturn NEW;\n-- this is actually ignored for an after trigger, but oh well\nend;\n$func$ language plpgsql volatile -- pldfplplpflh\ncost 100;\n-- default value\ncreate\nor replace trigger tg_user_history_count\nafter\ninsert\n  on history for each row execute procedure user_history_count();\n" rows_affected=0 rows_returned=0 elapsed=157.261µs
atuin-1  | Error: failed to connect to db: PostgresSettings { db_uri: "**redacted**" }
atuin-1  |
atuin-1  | Caused by:
atuin-1  |     Other(while executing migrations: error returned from database: syntax error at or near "trigger"
atuin-1  |
atuin-1  |     Caused by:
atuin-1  |        0: error returned from database: syntax error at or near "trigger"
atuin-1  |        1: syntax error at or near "trigger"
atuin-1  |
atuin-1  |     Location:
atuin-1  |         /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/convert/mod.rs:757:9)
atuin-1  |
atuin-1  | Location:
atuin-1  |     /app/atuin-server/src/lib.rs:141:10
atuin-1 exited with code 0
@johnnyasantoss
Copy link
Author

Just tested c00e54c and it fails with the same error.

@ellie
Copy link
Member

ellie commented Mar 11, 2024

I'm afraid atuin requires Postgres v14 as a minimum

@johnnyasantoss
Copy link
Author

I'm still backing up and migrating data from the pg instance but will report back once done. Thanks

@johnnyasantoss
Copy link
Author

Yes, after migrating to pg 16 it worked. Thank you

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

2 participants