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
This commit is contained in:
hengsin 2024-05-14 19:04:30 +08:00 committed by Carlos Ruiz
parent 4091c74093
commit c47db344e8
1 changed files with 7 additions and 2 deletions

View File

@ -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<String, DatabaseKey> htForeignKeys = new Hashtable<String, DatabaseKey>();
if (md.storesUpperCaseIdentifiers()) {