@loomcore/api 0.1.124 → 0.1.127

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.
@@ -41,15 +41,21 @@ export const getPostgresInitialSchema = (dbConfig) => {
41
41
  name: '00000000000002_schema-persons',
42
42
  up: async ({ context: pool }) => {
43
43
  const orgColumnDef = isMultiTenant ? '"_orgId" INTEGER,' : '';
44
+ const personsUniqueConstraints = isMultiTenant
45
+ ? `CONSTRAINT "uk_persons_org_external_id" UNIQUE ("_orgId", "external_id"),
46
+ CONSTRAINT "uk_persons_org_ssn" UNIQUE ("_orgId", "ssn")`
47
+ : `CONSTRAINT "uk_persons_external_id" UNIQUE ("external_id"),
48
+ CONSTRAINT "uk_persons_ssn" UNIQUE ("ssn")`;
44
49
  await pool.query(`
45
50
  CREATE TABLE IF NOT EXISTS "persons" (
46
51
  "_id" INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
47
52
  ${orgColumnDef}
48
- "external_id" VARCHAR(255) UNIQUE,
53
+ "external_id" VARCHAR(255),
49
54
  "first_name" VARCHAR(255) NOT NULL,
50
55
  "middle_name" VARCHAR(255),
51
56
  "last_name" VARCHAR(255) NOT NULL,
52
57
  "date_of_birth" DATE,
58
+ "ssn" BIGINT,
53
59
  "is_agent" BOOLEAN NOT NULL DEFAULT FALSE,
54
60
  "is_client" BOOLEAN NOT NULL DEFAULT FALSE,
55
61
  "is_employee" BOOLEAN NOT NULL DEFAULT FALSE,
@@ -59,7 +65,8 @@ export const getPostgresInitialSchema = (dbConfig) => {
59
65
  "_updated" TIMESTAMPTZ NOT NULL,
60
66
  "_updatedBy" INTEGER NOT NULL,
61
67
  "_deleted" TIMESTAMPTZ,
62
- "_deletedBy" INTEGER
68
+ "_deletedBy" INTEGER,
69
+ ${personsUniqueConstraints}
63
70
  )
64
71
  `);
65
72
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/api",
3
- "version": "0.1.124",
3
+ "version": "0.1.127",
4
4
  "private": false,
5
5
  "description": "Loom Core Api - An opinionated Node.js api using Typescript, Express, and MongoDb or PostgreSQL",
6
6
  "scripts": {