Skip to content

Commit

Permalink
Merge pull request #12620 from PasanT9/cascade-issue
Browse files Browse the repository at this point in the history
Remove cascade deletes in AI configurations
  • Loading branch information
PasanT9 authored Oct 2, 2024
2 parents 0c50d1b + a69da58 commit 154a878
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2753,6 +2753,9 @@ private void deleteAPIFromDB(API api) throws APIManagementException {
}
}
deleteScopes(localScopeKeysToDelete, tenantId);
if (APIConstants.API_SUBTYPE_AI_API.equals(api.getSubtype())) {
apiMgtDAO.deleteAIConfiguration(api.getUuid(), null);
}
apiMgtDAO.deleteAPI(api.getUuid());
if (log.isDebugEnabled()) {
log.debug("API : " + apiIdentifier + " is successfully deleted from the database and Key Manager.");
Expand Down Expand Up @@ -6722,6 +6725,7 @@ public void deleteAPIRevision(String apiId, String apiRevisionId, String organiz
ERROR_DELETING_API_REVISION,apiRevision.getApiUUID()));
}
apiMgtDAO.deleteAPIRevision(apiRevision);
apiMgtDAO.deleteAIConfiguration(apiRevision.getApiUUID(), apiRevision.getRevisionUUID());
gatewayArtifactsMgtDAO.deleteGatewayArtifact(apiRevision.getApiUUID(), apiRevision.getRevisionUUID());
if (artifactSaver != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2803,7 +2803,7 @@ public class SQLConstants {
"DELETE FROM AM_API_AI_CONFIGURATION WHERE API_UUID = ? AND API_REVISION_UUID = ?";

public static final String DELETE_AI_CONFIGURATIONS =
"DELETE FROM AM_API_AI_CONFIGURATION WHERE API_UUID = ? AND API_REVISION_UUID IS NULL";
"DELETE FROM AM_API_AI_CONFIGURATION WHERE API_UUID = ?";

public static final String DELETE_API_PRODUCT_SQL =
"DELETE FROM AM_API WHERE API_PROVIDER = ? AND API_NAME = ? AND API_VERSION = ? AND API_TYPE = '"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3284,7 +3284,7 @@ CREATE TABLE AM_API_AI_CONFIGURATION (
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
PRIMARY KEY (AI_CONFIGURATION_UUID),
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID) ON DELETE CASCADE,
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID),
FOREIGN KEY (LLM_PROVIDER_UUID) REFERENCES AM_LLM_PROVIDER(UUID)
)
/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2488,7 +2488,7 @@ CREATE TABLE IF NOT EXISTS AM_API_AI_CONFIGURATION (
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
PRIMARY KEY (AI_CONFIGURATION_UUID),
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID) ON DELETE CASCADE,
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID),
FOREIGN KEY (LLM_PROVIDER_UUID) REFERENCES AM_LLM_PROVIDER(UUID)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2762,7 +2762,7 @@ CREATE TABLE AM_API_AI_CONFIGURATION (
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
PRIMARY KEY (AI_CONFIGURATION_UUID),
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID) ON DELETE CASCADE,
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID),
FOREIGN KEY (LLM_PROVIDER_UUID) REFERENCES AM_LLM_PROVIDER(UUID)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,7 @@ CREATE TABLE IF NOT EXISTS AM_API_AI_CONFIGURATION (
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
PRIMARY KEY (AI_CONFIGURATION_UUID),
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID) ON DELETE CASCADE,
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID),
FOREIGN KEY (LLM_PROVIDER_UUID) REFERENCES AM_LLM_PROVIDER(UUID)
) ENGINE INNODB;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2674,7 +2674,7 @@ CREATE TABLE IF NOT EXISTS AM_API_AI_CONFIGURATION (
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
PRIMARY KEY (AI_CONFIGURATION_UUID),
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID) ON DELETE CASCADE,
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID),
FOREIGN KEY (LLM_PROVIDER_UUID) REFERENCES AM_LLM_PROVIDER(UUID)
) ENGINE=NDB;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3876,7 +3876,7 @@ CREATE TABLE AM_API_AI_CONFIGURATION (
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
PRIMARY KEY (AI_CONFIGURATION_UUID),
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID) ON DELETE CASCADE,
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID),
FOREIGN KEY (LLM_PROVIDER_UUID) REFERENCES AM_LLM_PROVIDER(UUID)
)
/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3876,7 +3876,7 @@ CREATE TABLE AM_API_AI_CONFIGURATION (
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
PRIMARY KEY (AI_CONFIGURATION_UUID),
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID) ON DELETE CASCADE,
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID),
FOREIGN KEY (LLM_PROVIDER_UUID) REFERENCES AM_LLM_PROVIDER(UUID)
)
/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3847,7 +3847,7 @@ CREATE TABLE AM_API_AI_CONFIGURATION (
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
PRIMARY KEY (AI_CONFIGURATION_UUID),
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID) ON DELETE CASCADE,
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID),
FOREIGN KEY (LLM_PROVIDER_UUID) REFERENCES AM_LLM_PROVIDER(UUID)
)
/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2863,7 +2863,7 @@ CREATE TABLE IF NOT EXISTS AM_API_AI_CONFIGURATION (
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
PRIMARY KEY (AI_CONFIGURATION_UUID),
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID) ON DELETE CASCADE,
FOREIGN KEY (API_UUID) REFERENCES AM_API(API_UUID),
FOREIGN KEY (LLM_PROVIDER_UUID) REFERENCES AM_LLM_PROVIDER(UUID)
);

Expand Down

0 comments on commit 154a878

Please sign in to comment.