From ea3dffe78d185c3223f275fd1f650861ed82d2c2 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Mon, 30 Jan 2023 15:38:36 +0530 Subject: [PATCH] 1) Fixed an issue where Query history is not getting loaded with an external database. #5781 2) Change the datatype of the value column of the setting table to text instead of a string. #5746 3) Fixed an issue where the key 'passfile' is not found. #4728 --- docs/en_US/release_notes_6_20.rst | 1 + web/migrations/versions/f656e56dfdc8_.py | 13 +++++++++---- web/pgadmin/__init__.py | 2 ++ .../browser/server_groups/servers/__init__.py | 2 +- web/pgadmin/model/__init__.py | 4 ++-- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/en_US/release_notes_6_20.rst b/docs/en_US/release_notes_6_20.rst index 539ccd9a6..a16a90cfc 100644 --- a/docs/en_US/release_notes_6_20.rst +++ b/docs/en_US/release_notes_6_20.rst @@ -32,3 +32,4 @@ Bug fixes | `Issue #5732 `_ - Fixed an issue where Kerberos authentication to the server is not imported/exported. | `Issue #5751 `_ - Fix failing import servers CLI due to vulnerability fix. | `Issue #5746 `_ - Increase the length of the value column of the setting table. + | `Issue #5781 `_ - Fixed an issue where Query history is not getting loaded with external database. diff --git a/web/migrations/versions/f656e56dfdc8_.py b/web/migrations/versions/f656e56dfdc8_.py index 24478fd08..648726490 100644 --- a/web/migrations/versions/f656e56dfdc8_.py +++ b/web/migrations/versions/f656e56dfdc8_.py @@ -67,10 +67,15 @@ def migrate_connection_params(table_name): .values(connection_params=connection_params) ) + # Drop constraint on ssl_mode column. + try: + with op.batch_alter_table(table_name) as batch_op: + batch_op.drop_constraint('ck_ssl_mode') + except Exception: + pass + # Drop unused columns with op.batch_alter_table(table_name) as batch_op: - if table_name == 'server': - batch_op.drop_constraint('ck_ssl_mode') batch_op.drop_column('ssl_mode') batch_op.drop_column('sslcert') batch_op.drop_column('sslkey') @@ -90,8 +95,8 @@ def upgrade(): with op.batch_alter_table("setting") as batch_op: batch_op.alter_column('value', existing_type=sa.String(length=1024), - type_=sa.String(length=2048), - existing_nullable=False) + type_=sa.Text(), + postgresql_using='value::text') def downgrade(): diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py index 9dadab767..82dce9d37 100644 --- a/web/pgadmin/__init__.py +++ b/web/pgadmin/__init__.py @@ -388,6 +388,8 @@ def create_app(app_name=None): db_upgrade(app) os.environ['CORRUPTED_DB_BACKUP_FILE'] = '' except Exception: + app.logger.error('Database migration failed') + app.logger.error(traceback.format_exc()) backup_db_file() # check all tables are present in the db. diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py index f674c167b..4b715f3c3 100644 --- a/web/pgadmin/browser/server_groups/servers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/__init__.py @@ -1147,7 +1147,7 @@ class ServerNode(PGChildNodeView): password = encrypt(password, crypt_key) elif 'passfile' in data['connection_params'] and \ data['connection_params']['passfile'] != '': - passfile = data['passfile'] + passfile = data['connection_params']['passfile'] if 'tunnel_password' in data and data["tunnel_password"] != '': have_tunnel_password = True diff --git a/web/pgadmin/model/__init__.py b/web/pgadmin/model/__init__.py index 540be22cd..8ebaa4d0e 100644 --- a/web/pgadmin/model/__init__.py +++ b/web/pgadmin/model/__init__.py @@ -132,7 +132,7 @@ class Setting(db.Model): __tablename__ = 'setting' user_id = db.Column(db.Integer, db.ForeignKey(USER_ID), primary_key=True) setting = db.Column(db.String(256), primary_key=True) - value = db.Column(db.String(1024)) + value = db.Column(db.Text()) class ServerGroup(db.Model): @@ -371,7 +371,7 @@ class QueryHistoryModel(db.Model): db.Integer(), db.ForeignKey(SERVER_ID), nullable=False, primary_key=True) dbname = db.Column(db.String(), nullable=False, primary_key=True) - query_info = db.Column(db.String(), nullable=False) + query_info = db.Column(PgAdminDbBinaryString(), nullable=False) last_updated_flag = db.Column(db.String(), nullable=False)