mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-11-03 12:49:23 -06:00
An old configuration database (e.g. a pre-9.0 pgadmin4.db lingering in %appdata%) can carry a stale foreign key such as server.user_id -> user_old, a table removed long ago. SQLAlchemy's MetaData.reflect() defaults to resolve_fks=True, which auto-follows the reflected table's foreign keys and reflects their targets too; the orphan target trips NoSuchTableError and aborts the startup migration, surfacing in the GUI as the misleading "Server could not be contacted". None of the migrations use the FK-target tables -- each operates only on the explicitly requested table(s). Pass resolve_fks=False at all 14 meta.reflect() call sites across the 12 migration files so reflection no longer cascades into broken FK targets. Behaviour is unchanged for healthy databases. Adds a 9.16 release note.
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
##########################################################################
|
|
#
|
|
# pgAdmin 4 - PostgreSQL Tools
|
|
#
|
|
# Copyright (C) 2013 - 2026, The pgAdmin Development Team
|
|
# This software is released under the PostgreSQL Licence
|
|
#
|
|
##########################################################################
|
|
""" Update the default timeout to 10 seconds instead on 0.
|
|
0 indicates wait indefinitely which causes trouble when network connection
|
|
to server is lost.
|
|
|
|
Revision ID: aff1436e3c8c
|
|
Revises: a77a0932a568
|
|
Create Date: 2019-10-28 12:47:36.828709
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'aff1436e3c8c'
|
|
down_revision = 'a77a0932a568'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# get metadata from current connection
|
|
meta = sa.MetaData()
|
|
# define table representation
|
|
meta.reflect(op.get_bind(), only=('server',), resolve_fks=False)
|
|
server_table = sa.Table('server', meta)
|
|
op.execute(
|
|
server_table.update().where(server_table.c.connect_timeout == 0 or
|
|
server_table.c.connect_timeout is None)
|
|
.values(connect_timeout=10)
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
# pgAdmin only upgrades, downgrade not implemented.
|
|
pass
|