-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix saving workspace services not working with pgconfig
Saving the workspace services not working with pgconfig when caching is enabled. `CachingGeoServerFacade` assumed there's nothing to do when a `ServiceInfo` is added for a workspace, but it was caching the `null` value, which is expected to save db roundtrips. - Add missing treatment of `ServiceInfoAdded` and `SettingInfoAdded` to `CachingGeoServerFacade`. - Add referential integrity for settingsinfo and serviceinfo Now the flyway migration will add referential integrity for: - `settingsinfo(workspace) -> workspaceindo(id)` - `serviceinfo(workspace) -> workspaceinfo(id)` And unique indexes for: - `settingsinfo(workspace)` - `serviceinfo("@type", workspace)` As a side effect of the caching facade returning null once a `ServiceInfo` as added, you could add multiple services of the same kind for a workspace. The referential integrity checks will avoid that, and the FlyWay migration will delete existing duplicates.
- Loading branch information
Showing
5 changed files
with
98 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...n/resources/db/pgconfig/migration/postgresql/V1_8__ServiceInfoSettingsInfoConstraints.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Add referential integrity constraint from: | ||
* | ||
* - settingsinfo(workspace) -> workspaceindo(id) | ||
* - serviceinfo(workspace) -> workspaceinfo(id) | ||
* | ||
* And unique indexes for: | ||
* | ||
* - settingsinfo(workspace) | ||
* - serviceinfo("@type", workspace) | ||
*/ | ||
|
||
|
||
ALTER TABLE settingsinfo | ||
ADD CONSTRAINT fk_settingsinfo_workspace | ||
FOREIGN KEY (workspace) | ||
REFERENCES workspaceinfo(id) | ||
ON DELETE CASCADE; | ||
|
||
CREATE UNIQUE INDEX settingsinfo_workspace_key | ||
ON settingsinfo (workspace) | ||
NULLS NOT DISTINCT; | ||
|
||
/* | ||
* Delete possible duplicate serviceinfos by type and workspace before enforcing uniqueness. | ||
*/ | ||
DELETE FROM serviceinfo WHERE id IN( select id FROM ( | ||
SELECT id, | ||
ROW_NUMBER() OVER(PARTITION BY "@type", workspace ORDER BY id ASC) AS duprow | ||
FROM serviceinfo | ||
) dups | ||
WHERE | ||
dups.duprow > 1); | ||
|
||
ALTER TABLE serviceinfo | ||
ADD CONSTRAINT fk_serviceinfo_workspace | ||
FOREIGN KEY (workspace) | ||
REFERENCES workspaceinfo(id) | ||
ON DELETE CASCADE; | ||
|
||
CREATE UNIQUE INDEX serviceinfo_workspace_key | ||
ON serviceinfo ("@type", workspace) | ||
NULLS NOT DISTINCT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters