mealie-recipes / mealie

Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relevant data or add a family recipe with the UI editor
https://docs.mealie.io
GNU Affero General Public License v3.0
5.78k stars 628 forks source link

[Error] - migrate from Postgres 15 to 16.2 #3511

Closed poudenes closed 3 months ago

poudenes commented 3 months ago

First Check

What is the issue you are experiencing?

Create new docker with new Postgres 16.2. Restored latest dB for Mealie into the new dB system

Updated the docker of mealie so it will read the new postgres location. Get a error and won't run.

Revert back and everything is working again on old dB on Postgres 15

Steps to Reproduce

na

Please provide relevant logs

[SQL: CREATE TABLE cookbooks_to_tags ( cookbook_id UUID, tag_id UUID, FOREIGN KEY(cookbook_id) REFERENCES cookbooks (id), FOREIGN KEY(tag_id) REFERENCES tags (id) ) ] (Background on this error at: https://sqlalche.me/e/20/f405) ERROR 2024-04-23T15:27:36 - Application startup failed. Exiting. ERROR 2024-04-23T15:27:36 - Traceback (most recent call last): File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context self.dialect.do_execute( File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute cursor.execute(statement, parameters) psycopg2.errors.UndefinedTable: relation "cookbooks" does not exist The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 732, in lifespan async with self.lifespan_context(app) as maybe_state: File "/usr/local/lib/python3.10/contextlib.py", line 199, in aenter return await anext(self.gen) File "/app/mealie/app.py", line 60, in lifespan_fn init_db.main() File "/app/mealie/db/init_db.py", line 101, in main command.upgrade(alembic_cfg, "head") File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/command.py", line 403, in upgrade script.run_env() File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/script/base.py", line 583, in run_env util.load_python_file(self.dir, "env.py") File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file module = load_module_py(module_id, path) File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py spec.loader.exec_module(module) # type: ignore File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/app/alembic/env.py", line 81, in run_migrations_online() File "/app/alembic/env.py", line 75, in run_migrations_online context.run_migrations() File "", line 8, in run_migrations File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/runtime/environment.py", line 948, in run_migrations self.get_context().run_migrations(kw) File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/runtime/migration.py", line 627, in run_migrations step.migration_fn(kw) File "/app/alembic/versions/2022-03-31-19.19.55_59eb59135381_add_tags_to_cookbooks.py", line 23, in upgrade op.create_table( File "", line 8, in create_table File "", line 3, in create_table File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/operations/ops.py", line 1311, in create_table return operations.invoke(op) File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/operations/base.py", line 445, in invoke return fn(self, operation) File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/operations/toimpl.py", line 131, in create_table operations.impl.create_table(table) File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/ddl/impl.py", line 366, in create_table self._exec(schema.CreateTable(table)) File "/opt/pysetup/.venv/lib/python3.10/site-packages/alembic/ddl/impl.py", line 207, in _exec return conn.execute(construct, multiparams) File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1422, in execute return meth( File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/sql/ddl.py", line 180, in _execute_on_connection return connection._execute_ddl( File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1533, in _execute_ddl ret = self._execute_context( File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1850, in _execute_context return self._exec_single_context( File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1990, in _exec_single_context self._handle_dbapi_exception( File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2357, in _handle_dbapi_exception raise sqlalchemy_exception.with_traceback(exc_info[2]) from e File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1971, in _exec_single_context self.dialect.do_execute( File "/opt/pysetup/.venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 919, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "cookbooks" does not exist [SQL: CREATE TABLE cookbooks_to_tags ( cookbook_id UUID, tag_id UUID, FOREIGN KEY(cookbook_id) REFERENCES cookbooks (id), FOREIGN KEY(tag_id) REFERENCES tags (id) ) ] (Background on this error at: https://sqlalche.me/e/20/f405) ERROR 2024-04-23T15:27:36 - Application startup failed. Exiting.

Mealie Version

1.5.1

ghcr.io/mealie-recipes/mealie:latest

Deployment

Docker (Synology)

Additional Deployment Details

No response

poudenes commented 3 months ago

Create a backup in old situation. Changed everything and restored the backup. Now it working.