From 799123c341d6796a6f1b749e8f6cc0df11d85e1e Mon Sep 17 00:00:00 2001 From: Aarol D'Souza <98270103+AarDG10@users.noreply.github.com> Date: Mon, 29 Dec 2025 18:29:22 +0530 Subject: [PATCH] perf(postgres): skip unnecessary migrations due to type mismatch (#34784) --- frappe/database/postgres/database.py | 4 +++- frappe/tests/test_db_update.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frappe/database/postgres/database.py b/frappe/database/postgres/database.py index 6ec1374343..f68d36e205 100644 --- a/frappe/database/postgres/database.py +++ b/frappe/database/postgres/database.py @@ -444,6 +444,8 @@ class PostgresDatabase(PostgresExceptionUtil, Database): CASE LOWER(a.data_type) WHEN 'character varying' THEN CONCAT('varchar(', a.character_maximum_length ,')') WHEN 'timestamp without time zone' THEN 'timestamp' + WHEN 'integer' THEN 'int' + WHEN 'numeric' THEN CONCAT('decimal(', a.numeric_precision, ',', a.numeric_scale, ')') ELSE a.data_type END AS type, BOOL_OR(b.index) AS index, @@ -460,7 +462,7 @@ class PostgresDatabase(PostgresExceptionUtil, Database): ON SUBSTRING(b.indexdef, '(.*)') LIKE CONCAT('%', a.column_name, '%') WHERE a.table_name = '{table_name}' AND a.table_schema = '{self.db_schema}' - GROUP BY a.column_name, a.data_type, a.column_default, a.character_maximum_length, a.is_nullable; + GROUP BY a.column_name, a.data_type, a.column_default, a.character_maximum_length, a.is_nullable, a.numeric_precision, a.numeric_scale; """, as_dict=1, ) diff --git a/frappe/tests/test_db_update.py b/frappe/tests/test_db_update.py index 5deb94cccb..89fe503342 100644 --- a/frappe/tests/test_db_update.py +++ b/frappe/tests/test_db_update.py @@ -1,4 +1,5 @@ import random +from unittest.case import skipIf import frappe from frappe.core.doctype.doctype.test_doctype import new_doctype @@ -207,7 +208,10 @@ class TestDBUpdate(IntegrationTestCase): class TestDBUpdateSanityChecks(IntegrationTestCase): - @run_only_if(db_type_is.MARIADB) + @skipIf( + (frappe.conf.db_type == "sqlite"), + "Not for SQLite for now", + ) def test_no_unnecessary_migrates(self): doctypes = frappe.get_all("DocType", {"is_virtual": 0, "custom": 0}, pluck="name")