@axinom/mosaic-db-common 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.6.0](https://dev.azure.com/axinom/CMS/_git/Navy/branchCompare?baseVersion=GT@axinom/mosaic-db-common@0.4.2&targetVersion=GT@axinom/mosaic-db-common@0.6.0) (2021-10-25)
7
+
8
+
9
+ ### Features
10
+
11
+ * added snippets and helpers for unique constraints ([068f466](https://dev.azure.com/axinom/CMS/_git/Navy/commit/068f4665a4b264697f0e9d7b7df859298b1ecd1d)), closes [#33146](https://dev.azure.com/axinom/CMS/_workitems/edit/33146)
12
+ * pg pool error handling adjusted ([ba18103](https://dev.azure.com/axinom/CMS/_git/Navy/commit/ba18103c941bb568f7bff08cf791bcec96e458b9)), closes [#32254](https://dev.azure.com/axinom/CMS/_workitems/edit/32254)
13
+
14
+
15
+
6
16
  ## [0.5.0](https://dev.azure.com/axinom/CMS/_git/Navy/branchCompare?baseVersion=GT@axinom/mosaic-db-common@0.4.2&targetVersion=GT@axinom/mosaic-db-common@0.5.0) (2021-10-13)
7
17
 
8
18
 
@@ -151,16 +151,34 @@ BEGIN
151
151
  END;
152
152
  $$;
153
153
 
154
+ CREATE OR REPLACE FUNCTION ax_utils.drop_unique_constraint(fieldName text, tableName text, schemaName text) RETURNS void
155
+ LANGUAGE plpgsql
156
+ AS $$
157
+ BEGIN
158
+ EXECUTE 'ALTER TABLE ' || schemaName || '.' || tableName || ' DROP CONSTRAINT IF EXISTS ' || tableName || '_' || fieldName || '_is_unique;';
159
+ END;
160
+ $$;
161
+
154
162
  -- creation method to help on consistently create UNIQUE constraint in an idempotent way
155
163
  CREATE OR REPLACE FUNCTION ax_utils.define_unique_constraint(fieldName text, tableName text, schemaName text) RETURNS void
156
164
  LANGUAGE plpgsql
157
165
  AS $$
158
166
  BEGIN
159
- EXECUTE 'ALTER TABLE ' || schemaName || '.' || tableName || ' DROP CONSTRAINT IF EXISTS ' || tableName || '_' || fieldName || '_is_unique;';
167
+ PERFORM ax_utils.drop_unique_constraint(fieldName, tableName, schemaName);
160
168
  EXECUTE 'ALTER TABLE ' || schemaName || '.' || tableName || ' ADD CONSTRAINT ' || tableName || '_' || fieldName || '_is_unique UNIQUE (' || fieldName || ');';
161
169
  END;
162
170
  $$;
163
171
 
172
+ -- creation method to help on consistently create UNIQUE deferred constraint in an idempotent way. Uniqueness is only checked when the transaction is committed.
173
+ CREATE OR REPLACE FUNCTION ax_utils.define_deferred_unique_constraint(fieldName text, tableName text, schemaName text) RETURNS void
174
+ LANGUAGE plpgsql
175
+ AS $$
176
+ BEGIN
177
+ PERFORM ax_utils.drop_unique_constraint(fieldName, tableName, schemaName);
178
+ EXECUTE 'ALTER TABLE ' || schemaName || '.' || tableName || ' ADD CONSTRAINT ' || tableName || '_' || fieldName || '_is_unique UNIQUE (' || fieldName || ') DEFERRABLE INITIALLY DEFERRED;';
179
+ END;
180
+ $$;
181
+
164
182
  -- deletion method to help on consistently delete index that support LIKE/ILIKE searches
165
183
  CREATE OR REPLACE FUNCTION ax_utils.drop_like_index(fieldName text, tableName text) RETURNS void
166
184
  LANGUAGE plpgsql
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-db-common",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "This library encapsulates database-related functionality to develop Mosaic based services.",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "e5bc318478f8fae8cecd491fcd6c8ad52ec877fe"
48
+ "gitHead": "c28cbe4b82c11f28de37913558f34833b49c4b6c"
49
49
  }