From c47db344e8c4e4520d2560a9091d8dbe7b573ebd Mon Sep 17 00:00:00 2001 From: hengsin Date: Tue, 14 May 2024 19:04:30 +0800 Subject: [PATCH] IDEMPIERE-6142 Can't add new column to partitioned table (#2358) * IDEMPIERE-6142 Can't add new column to partitioned table * IDEMPIERE-6142 Can't add new column to partitioned table - Fix issue with foreign key * IDEMPIERE-6142 Can't add new column to partitioned table - Fix issue with foreign key --- org.adempiere.base/src/org/compiere/model/MColumn.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MColumn.java b/org.adempiere.base/src/org/compiere/model/MColumn.java index 98241913cb..7757e91dd2 100644 --- a/org.adempiere.base/src/org/compiere/model/MColumn.java +++ b/org.adempiere.base/src/org/compiere/model/MColumn.java @@ -592,11 +592,12 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport setSeqNoPartition(ii); } - if (is_ValueChanged(COLUMNNAME_IsPartitionKey) + // Validate partition column changes + if (!newRecord && (is_ValueChanged(COLUMNNAME_IsPartitionKey) || is_ValueChanged(COLUMNNAME_PartitioningMethod) || (isPartitionKey() && is_ValueChanged(COLUMNNAME_IsActive)) || (isPartitionKey() && is_ValueChanged(COLUMNNAME_SeqNoPartition)) - || (isPartitionKey() && is_ValueChanged(COLUMNNAME_RangePartitionInterval))) { + || (isPartitionKey() && is_ValueChanged(COLUMNNAME_RangePartitionInterval)))) { ITablePartitionService service = DB.getDatabase().getTablePartitionService(); if (service == null) { log.saveError("Error", Msg.getMsg(getCtx(), "DBAdapterNoTablePartitionSupport")); @@ -1034,6 +1035,10 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport String referenceTableName = column.getReferenceTableName(); if (referenceTableName != null) { + // Fk doesn't work for partitioned PostgreSQL table + if (DB.isPostgreSQL() && MTable.get(Env.getCtx(), referenceTableName) != null && MTable.get(Env.getCtx(), referenceTableName).isPartition()) + return null; + Hashtable htForeignKeys = new Hashtable(); if (md.storesUpperCaseIdentifiers()) {