Added to existing issue https://github.com/pgadmin-org/pgadmin4/issues/7266#issuecomment-1987956752. ..
On Mon, 11 Mar 2024 at 03:17, Khushboo Vashi < khushboo.va...@enterprisedb.com> wrote: > > > On Sun, Mar 10, 2024 at 7:06 PM Shaheed Haque <shaheedha...@gmail.com> > wrote: > >> OK, it looks as though this problem occurs newly in flask-migrate 4.0.6. >> It looks as though the changes here: >> >> >> https://github.com/miguelgrinberg/Flask-Migrate/commit/6f3f889c36030134f87dc1db327c2385d873a4d6 >> >> introduce some new behaviour which I guess pgadmin4 does not yet support. >> Can I gently request that the pgadmin4 team look into this further? I am of >> course happy to test as needed. >> >> Please log a request @ https://github.com/pgadmin-org/pgadmin4/issues > >> Thanks, Shaheed >> >> On Sun, 10 Mar 2024 at 10:56, Shaheed Haque <shaheedha...@gmail.com> >> wrote: >> >>> Hi, >>> >>> I have a scripted install for pgadmin4 which worked as expected for >>> pgadmin7.7 when last used. I'm now trying to install 8.4 in a new VM, and >>> it fails like this: >>> >>> $ sudo -i -u ubuntu PGADMIN_SETUP_EMAIL=x...@123.com >>> PGADMIN_SETUP_PASSWORD=abcd python3 >>> /home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/setup.py setup-db >>> 2024-03-10 03:13:21,163: ERROR pgadmin: Database migration failed >>> 2024-03-10 03:13:21,164: ERROR pgadmin: Traceback (most recent >>> call last): >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py", >>> line 386, in upgrade_db >>> db_upgrade(app) >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/setup/db_upgrade.py", >>> line 22, in db_upgrade >>> flask_migrate.upgrade(migration_folder) >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", >>> line 111, in wrapped >>> f(*args, **kwargs) >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", >>> line 198, in upgrade >>> config = >>> current_app.extensions['migrate'].migrate.get_config(directory, >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", >>> line 96, in get_config >>> for x in g.x_arg: >>> File "/home/ubuntu/venv/lib/python3.10/site-packages/flask/ctx.py", >>> line 54, in __getattr__ >>> raise AttributeError(name) from None >>> AttributeError: x_arg >>> ... >>> ascii art traceback >>> ... >>> AttributeError: x_arg >>> >>> During handling of the above exception, another exception occurred: >>> ... >>> ascii art traceback >>> ... >>> FileNotFoundError: [Errno 2] No such file or directory: >>> '/var/lib/pgadmin/pgadmin4.db' -> >>> '/var/lib/pgadmin/pgadmin4.db.20240310031321' >>> >>> Note: the argument "setup-db" was not previously used, but seems >>> required now. I've enclosed the output of "pip freeze" below. I have >>> verified that the directory "/var/lib/pgadmin" exists, and is writeable by >>> the user "ubuntu". In the same directory as setup.py is the following file: >>> >>> $ cat >>> /home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/config_local.py >>> LOG_FILE = '/var/log/pgadmin/pgadmin4.log' >>> SQLITE_PATH = '/var/lib/pgadmin/pgadmin4.db' >>> SESSION_DB_PATH = '/var/lib/pgadmin/sessions' >>> STORAGE_DIR = '/var/lib/pgadmin/storage' >>> AZURE_CREDENTIAL_CACHE_DIR = '/var/lib/pgadmin/azurecredentialcache' >>> <<< new entry >>> KERBEROS_CCACHE_DIR = '/var/lib/pgadmin/kerberoscache' >>> <<< new entry >>> SERVER_MODE = True >>> >>> Note: I have highlighted a couple of entries which I added after reading >>> the current installation documentation. I also tried launching the VM with >>> the previously working pgadmin4 7.7 >>> >>> $ sudo -i -u ubuntu PGADMIN_SETUP_EMAIL=1...@123.com >>> PGADMIN_SETUP_PASSWORD=abcdedg python3 >>> /home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/setup.py setup-db >>> 2024-03-10 10:04:24,371: ERROR pgadmin: Database migration failed >>> 2024-03-10 10:04:24,372: ERROR pgadmin: Traceback (most recent >>> call last): >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py", >>> line 390, in upgrade_db >>> db_upgrade(app) >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/setup/db_upgrade.py", >>> line 25, in db_upgrade >>> flask_migrate.upgrade(migration_folder) >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", >>> line 111, in wrapped >>> f(*args, **kwargs) >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", >>> line 198, in upgrade >>> config = >>> current_app.extensions['migrate'].migrate.get_config(directory, >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", >>> line 96, in get_config >>> for x in g.x_arg: >>> File "/home/ubuntu/venv/lib/python3.10/site-packages/flask/ctx.py", >>> line 52, in __getattr__ >>> raise AttributeError(name) from None >>> AttributeError: x_arg >>> Traceback (most recent call last): >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py", >>> line 390, in upgrade_db >>> db_upgrade(app) >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/setup/db_upgrade.py", >>> line 25, in db_upgrade >>> flask_migrate.upgrade(migration_folder) >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", >>> line 111, in wrapped >>> f(*args, **kwargs) >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", >>> line 198, in upgrade >>> config = >>> current_app.extensions['migrate'].migrate.get_config(directory, >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", >>> line 96, in get_config >>> for x in g.x_arg: >>> File "/home/ubuntu/venv/lib/python3.10/site-packages/flask/ctx.py", >>> line 52, in __getattr__ >>> raise AttributeError(name) from None >>> AttributeError: x_arg >>> During handling of the above exception, another exception occurred: >>> Traceback (most recent call last): >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/setup.py", line >>> 220, in <module> >>> app = create_app() >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py", >>> line 477, in create_app >>> run_migration_for_sqlite() >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py", >>> line 414, in run_migration_for_sqlite >>> upgrade_db() >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py", >>> line 395, in upgrade_db >>> backup_db_file() >>> File >>> "/home/ubuntu/venv/lib/python3.10/site-packages/pgadmin4/pgadmin/__init__.py", >>> line 372, in backup_db_file >>> os.rename(SQLITE_PATH, backup_file_name) >>> FileNotFoundError: [Errno 2] No such file or directory: >>> '/var/lib/pgadmin/pgadmin4.db' -> >>> '/var/lib/pgadmin/pgadmin4.db.20240310100424' >>> >>> Note that 7.7 fails in the same way with or without the newly added >>> "setup-db" argument. Given this pattern, my guess is that flask-migrate or >>> flask is possibly the issue, rather than pgadmin4, but I have not been able >>> to debug/confirm that. >>> >>> Any advice appreciated. >>> >>> Thanks, Shaheed >>> >>> Ecls: pip freeze output... >>> >>> (venv) srhaque-paiyroll-28edd545c2 pip freeze >>> ... >>> Flask==2.3.3 >>> flask-babel==4.0.0 >>> Flask-Compress==1.14 >>> Flask-Gravatar==0.5.0 >>> Flask-Login==0.6.3 >>> Flask-Mail==0.9.1 >>> Flask-Migrate==4.0.6 >>> Flask-Paranoid==0.3.0 >>> Flask-Principal==0.4.0 >>> Flask-Security-Too==5.3.3 >>> Flask-SocketIO==5.3.6 >>> Flask-SQLAlchemy==3.1.1 >>> Flask-WTF==1.2.1 >>> ... >>> pgadmin4==8.4 >>> >>