@loomcore/api 0.1.147 → 0.1.149
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.
|
@@ -16,8 +16,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
16
16
|
"count" INTEGER,
|
|
17
17
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
18
18
|
"_createdBy" INTEGER NOT NULL,
|
|
19
|
-
"_updated" TIMESTAMPTZ
|
|
20
|
-
"_updatedBy" INTEGER
|
|
19
|
+
"_updated" TIMESTAMPTZ,
|
|
20
|
+
"_updatedBy" INTEGER,
|
|
21
21
|
"_deleted" TIMESTAMPTZ,
|
|
22
22
|
"_deletedBy" INTEGER
|
|
23
23
|
)
|
|
@@ -57,8 +57,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
57
57
|
"category_id" INTEGER NOT NULL,
|
|
58
58
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
59
59
|
"_createdBy" INTEGER NOT NULL,
|
|
60
|
-
"_updated" TIMESTAMPTZ
|
|
61
|
-
"_updatedBy" INTEGER
|
|
60
|
+
"_updated" TIMESTAMPTZ,
|
|
61
|
+
"_updatedBy" INTEGER,
|
|
62
62
|
"_deleted" TIMESTAMPTZ,
|
|
63
63
|
"_deletedBy" INTEGER,
|
|
64
64
|
CONSTRAINT "fk_products_category" FOREIGN KEY ("category_id") REFERENCES "categories"("_id") ON DELETE CASCADE
|
|
@@ -82,8 +82,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
82
82
|
"event_date" TIMESTAMPTZ,
|
|
83
83
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
84
84
|
"_createdBy" INTEGER NOT NULL,
|
|
85
|
-
"_updated" TIMESTAMPTZ
|
|
86
|
-
"_updatedBy" INTEGER
|
|
85
|
+
"_updated" TIMESTAMPTZ,
|
|
86
|
+
"_updatedBy" INTEGER,
|
|
87
87
|
"_deleted" TIMESTAMPTZ,
|
|
88
88
|
"_deletedBy" INTEGER
|
|
89
89
|
)
|
|
@@ -104,8 +104,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
104
104
|
"person_id" INTEGER NOT NULL UNIQUE,
|
|
105
105
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
106
106
|
"_createdBy" INTEGER NOT NULL,
|
|
107
|
-
"_updated" TIMESTAMPTZ
|
|
108
|
-
"_updatedBy" INTEGER
|
|
107
|
+
"_updated" TIMESTAMPTZ,
|
|
108
|
+
"_updatedBy" INTEGER,
|
|
109
109
|
"_deleted" TIMESTAMPTZ,
|
|
110
110
|
"_deletedBy" INTEGER,
|
|
111
111
|
CONSTRAINT fk_agents_person_id FOREIGN KEY ("person_id") REFERENCES persons("_id") ON DELETE CASCADE
|
|
@@ -129,8 +129,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
129
129
|
"agent_id" INTEGER,
|
|
130
130
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
131
131
|
"_createdBy" INTEGER NOT NULL,
|
|
132
|
-
"_updated" TIMESTAMPTZ
|
|
133
|
-
"_updatedBy" INTEGER
|
|
132
|
+
"_updated" TIMESTAMPTZ,
|
|
133
|
+
"_updatedBy" INTEGER,
|
|
134
134
|
"_deleted" TIMESTAMPTZ,
|
|
135
135
|
"_deletedBy" INTEGER,
|
|
136
136
|
CONSTRAINT fk_clients_person_id FOREIGN KEY ("person_id") REFERENCES persons("_id") ON DELETE CASCADE,
|
|
@@ -155,8 +155,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
155
155
|
"frequency" VARCHAR NOT NULL,
|
|
156
156
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
157
157
|
"_createdBy" INTEGER NOT NULL,
|
|
158
|
-
"_updated" TIMESTAMPTZ
|
|
159
|
-
"_updatedBy" INTEGER
|
|
158
|
+
"_updated" TIMESTAMPTZ,
|
|
159
|
+
"_updatedBy" INTEGER,
|
|
160
160
|
"_deleted" TIMESTAMPTZ,
|
|
161
161
|
"_deletedBy" INTEGER,
|
|
162
162
|
CONSTRAINT fk_policies_client_id FOREIGN KEY ("client_id") REFERENCES clients("_id") ON DELETE CASCADE
|
|
@@ -179,8 +179,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
179
179
|
"agent_id" INTEGER NOT NULL,
|
|
180
180
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
181
181
|
"_createdBy" INTEGER NOT NULL,
|
|
182
|
-
"_updated" TIMESTAMPTZ
|
|
183
|
-
"_updatedBy" INTEGER
|
|
182
|
+
"_updated" TIMESTAMPTZ,
|
|
183
|
+
"_updatedBy" INTEGER,
|
|
184
184
|
"_deleted" TIMESTAMPTZ,
|
|
185
185
|
"_deletedBy" INTEGER,
|
|
186
186
|
CONSTRAINT fk_agents_policies_policy_id FOREIGN KEY ("policy_id") REFERENCES policies("_id") ON DELETE CASCADE,
|
|
@@ -206,8 +206,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
206
206
|
"date" DATE NOT NULL,
|
|
207
207
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
208
208
|
"_createdBy" INTEGER NOT NULL,
|
|
209
|
-
"_updated" TIMESTAMPTZ
|
|
210
|
-
"_updatedBy" INTEGER
|
|
209
|
+
"_updated" TIMESTAMPTZ,
|
|
210
|
+
"_updatedBy" INTEGER,
|
|
211
211
|
"_deleted" TIMESTAMPTZ,
|
|
212
212
|
"_deletedBy" INTEGER,
|
|
213
213
|
CONSTRAINT fk_premiums_policy_id FOREIGN KEY ("policy_id") REFERENCES policies("_id") ON DELETE CASCADE
|
|
@@ -233,8 +233,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
233
233
|
"is_default" BOOLEAN NOT NULL,
|
|
234
234
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
235
235
|
"_createdBy" INTEGER NOT NULL,
|
|
236
|
-
"_updated" TIMESTAMPTZ
|
|
237
|
-
"_updatedBy" INTEGER
|
|
236
|
+
"_updated" TIMESTAMPTZ,
|
|
237
|
+
"_updatedBy" INTEGER,
|
|
238
238
|
"_deleted" TIMESTAMPTZ,
|
|
239
239
|
"_deletedBy" INTEGER,
|
|
240
240
|
CONSTRAINT fk_email_addresses_person_id FOREIGN KEY ("person_id") REFERENCES persons("_id") ON DELETE CASCADE
|
|
@@ -259,8 +259,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
259
259
|
"is_default" BOOLEAN NOT NULL DEFAULT FALSE,
|
|
260
260
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
261
261
|
"_createdBy" INTEGER NOT NULL,
|
|
262
|
-
"_updated" TIMESTAMPTZ
|
|
263
|
-
"_updatedBy" INTEGER
|
|
262
|
+
"_updated" TIMESTAMPTZ,
|
|
263
|
+
"_updatedBy" INTEGER,
|
|
264
264
|
"_deleted" TIMESTAMPTZ,
|
|
265
265
|
"_deletedBy" INTEGER
|
|
266
266
|
)
|
|
@@ -288,8 +288,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
288
288
|
"country" VARCHAR NOT NULL,
|
|
289
289
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
290
290
|
"_createdBy" INTEGER NOT NULL,
|
|
291
|
-
"_updated" TIMESTAMPTZ
|
|
292
|
-
"_updatedBy" INTEGER
|
|
291
|
+
"_updated" TIMESTAMPTZ,
|
|
292
|
+
"_updatedBy" INTEGER,
|
|
293
293
|
"_deleted" TIMESTAMPTZ,
|
|
294
294
|
"_deletedBy" INTEGER
|
|
295
295
|
)
|
|
@@ -311,8 +311,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
311
311
|
"person_id" INTEGER NOT NULL,
|
|
312
312
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
313
313
|
"_createdBy" INTEGER NOT NULL,
|
|
314
|
-
"_updated" TIMESTAMPTZ
|
|
315
|
-
"_updatedBy" INTEGER
|
|
314
|
+
"_updated" TIMESTAMPTZ,
|
|
315
|
+
"_updatedBy" INTEGER,
|
|
316
316
|
"_deleted" TIMESTAMPTZ,
|
|
317
317
|
"_deletedBy" INTEGER,
|
|
318
318
|
CONSTRAINT fk_persons_addresses_address_id FOREIGN KEY ("address_id") REFERENCES addresses("_id") ON DELETE CASCADE,
|
|
@@ -337,8 +337,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
337
337
|
"person_id" INTEGER NOT NULL,
|
|
338
338
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
339
339
|
"_createdBy" INTEGER NOT NULL,
|
|
340
|
-
"_updated" TIMESTAMPTZ
|
|
341
|
-
"_updatedBy" INTEGER
|
|
340
|
+
"_updated" TIMESTAMPTZ,
|
|
341
|
+
"_updatedBy" INTEGER,
|
|
342
342
|
"_deleted" TIMESTAMPTZ,
|
|
343
343
|
"_deletedBy" INTEGER,
|
|
344
344
|
CONSTRAINT fk_persons_phone_numbers_phone_number_id FOREIGN KEY ("phone_number_id") REFERENCES phone_numbers("_id") ON DELETE CASCADE,
|
|
@@ -362,8 +362,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
362
362
|
"name" VARCHAR NOT NULL,
|
|
363
363
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
364
364
|
"_createdBy" INTEGER NOT NULL,
|
|
365
|
-
"_updated" TIMESTAMPTZ
|
|
366
|
-
"_updatedBy" INTEGER
|
|
365
|
+
"_updated" TIMESTAMPTZ,
|
|
366
|
+
"_updatedBy" INTEGER,
|
|
367
367
|
"_deleted" TIMESTAMPTZ,
|
|
368
368
|
"_deletedBy" INTEGER
|
|
369
369
|
)
|
|
@@ -385,8 +385,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
385
385
|
"state_id" INTEGER NOT NULL,
|
|
386
386
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
387
387
|
"_createdBy" INTEGER NOT NULL,
|
|
388
|
-
"_updated" TIMESTAMPTZ
|
|
389
|
-
"_updatedBy" INTEGER
|
|
388
|
+
"_updated" TIMESTAMPTZ,
|
|
389
|
+
"_updatedBy" INTEGER,
|
|
390
390
|
"_deleted" TIMESTAMPTZ,
|
|
391
391
|
"_deletedBy" INTEGER,
|
|
392
392
|
CONSTRAINT fk_districts_state_id FOREIGN KEY ("state_id") REFERENCES states("_id") ON DELETE CASCADE
|
|
@@ -409,8 +409,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
409
409
|
"district_id" INTEGER NOT NULL,
|
|
410
410
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
411
411
|
"_createdBy" INTEGER NOT NULL,
|
|
412
|
-
"_updated" TIMESTAMPTZ
|
|
413
|
-
"_updatedBy" INTEGER
|
|
412
|
+
"_updated" TIMESTAMPTZ,
|
|
413
|
+
"_updatedBy" INTEGER,
|
|
414
414
|
"_deleted" TIMESTAMPTZ,
|
|
415
415
|
"_deletedBy" INTEGER,
|
|
416
416
|
CONSTRAINT fk_schools_district_id FOREIGN KEY ("district_id") REFERENCES districts("_id") ON DELETE CASCADE
|
|
@@ -433,8 +433,8 @@ export const getPostgresTestSchema = (config) => {
|
|
|
433
433
|
"school_id" INTEGER NOT NULL,
|
|
434
434
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
435
435
|
"_createdBy" INTEGER NOT NULL,
|
|
436
|
-
"_updated" TIMESTAMPTZ
|
|
437
|
-
"_updatedBy" INTEGER
|
|
436
|
+
"_updated" TIMESTAMPTZ,
|
|
437
|
+
"_updatedBy" INTEGER,
|
|
438
438
|
"_deleted" TIMESTAMPTZ,
|
|
439
439
|
"_deletedBy" INTEGER,
|
|
440
440
|
CONSTRAINT fk_persons_schools_person_id FOREIGN KEY ("person_id") REFERENCES persons("_id") ON DELETE CASCADE,
|
|
@@ -20,8 +20,6 @@ export function getTestMetaOrg() {
|
|
|
20
20
|
isMetaOrg: true,
|
|
21
21
|
_created: new Date(),
|
|
22
22
|
_createdBy: 'system',
|
|
23
|
-
_updated: new Date(),
|
|
24
|
-
_updatedBy: 'system',
|
|
25
23
|
};
|
|
26
24
|
}
|
|
27
25
|
;
|
|
@@ -36,8 +34,6 @@ export function getTestMetaOrgUser() {
|
|
|
36
34
|
password: TEST_META_ORG_USER_PASSWORD,
|
|
37
35
|
_created: new Date(),
|
|
38
36
|
_createdBy: 'system',
|
|
39
|
-
_updated: new Date(),
|
|
40
|
-
_updatedBy: 'system',
|
|
41
37
|
};
|
|
42
38
|
}
|
|
43
39
|
export function getTestMetaOrgUserPerson() {
|
|
@@ -52,8 +48,6 @@ export function getTestMetaOrgUserPerson() {
|
|
|
52
48
|
isEmployee: false,
|
|
53
49
|
_created: new Date(),
|
|
54
50
|
_createdBy: 'system',
|
|
55
|
-
_updated: new Date(),
|
|
56
|
-
_updatedBy: 'system',
|
|
57
51
|
};
|
|
58
52
|
return person;
|
|
59
53
|
}
|
|
@@ -92,8 +86,6 @@ export function getTestOrg() {
|
|
|
92
86
|
isMetaOrg: false,
|
|
93
87
|
_created: new Date(),
|
|
94
88
|
_createdBy: 'system',
|
|
95
|
-
_updated: new Date(),
|
|
96
|
-
_updatedBy: 'system',
|
|
97
89
|
};
|
|
98
90
|
}
|
|
99
91
|
;
|
|
@@ -109,8 +101,6 @@ export function getTestOrgUser() {
|
|
|
109
101
|
password: TEST_ORG_USER_PASSWORD,
|
|
110
102
|
_created: new Date(),
|
|
111
103
|
_createdBy: 'system',
|
|
112
|
-
_updated: new Date(),
|
|
113
|
-
_updatedBy: 'system',
|
|
114
104
|
};
|
|
115
105
|
}
|
|
116
106
|
export function getTestOrgUserPerson() {
|
|
@@ -125,8 +115,6 @@ export function getTestOrgUserPerson() {
|
|
|
125
115
|
isEmployee: false,
|
|
126
116
|
_created: new Date(),
|
|
127
117
|
_createdBy: 'system',
|
|
128
|
-
_updated: new Date(),
|
|
129
|
-
_updatedBy: 'system',
|
|
130
118
|
};
|
|
131
119
|
}
|
|
132
120
|
export function getTestOrgUserContext() {
|
|
@@ -40,8 +40,8 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
40
40
|
"auth_token" TEXT,
|
|
41
41
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
42
42
|
"_createdBy" INTEGER NOT NULL,
|
|
43
|
-
"_updated" TIMESTAMPTZ
|
|
44
|
-
"_updatedBy" INTEGER
|
|
43
|
+
"_updated" TIMESTAMPTZ,
|
|
44
|
+
"_updatedBy" INTEGER,
|
|
45
45
|
"_deleted" TIMESTAMPTZ,
|
|
46
46
|
"_deletedBy" INTEGER
|
|
47
47
|
)
|
|
@@ -78,8 +78,8 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
78
78
|
"extended_types" INTEGER,
|
|
79
79
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
80
80
|
"_createdBy" INTEGER NOT NULL,
|
|
81
|
-
"_updated" TIMESTAMPTZ
|
|
82
|
-
"_updatedBy" INTEGER
|
|
81
|
+
"_updated" TIMESTAMPTZ,
|
|
82
|
+
"_updatedBy" INTEGER,
|
|
83
83
|
"_deleted" TIMESTAMPTZ,
|
|
84
84
|
"_deletedBy" INTEGER,
|
|
85
85
|
${personsUniqueConstraints}
|
|
@@ -116,8 +116,8 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
116
116
|
"_lastPasswordChange" TIMESTAMPTZ,
|
|
117
117
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
118
118
|
"_createdBy" INTEGER NOT NULL,
|
|
119
|
-
"_updated" TIMESTAMPTZ
|
|
120
|
-
"_updatedBy" INTEGER
|
|
119
|
+
"_updated" TIMESTAMPTZ,
|
|
120
|
+
"_updatedBy" INTEGER,
|
|
121
121
|
"_deleted" TIMESTAMPTZ,
|
|
122
122
|
"_deletedBy" INTEGER,
|
|
123
123
|
${uniqueConstraint}
|
|
@@ -173,8 +173,8 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
173
173
|
"expires_on" BIGINT NOT NULL,
|
|
174
174
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
175
175
|
"_createdBy" INTEGER NOT NULL,
|
|
176
|
-
"_updated" TIMESTAMPTZ
|
|
177
|
-
"_updatedBy" INTEGER
|
|
176
|
+
"_updated" TIMESTAMPTZ,
|
|
177
|
+
"_updatedBy" INTEGER,
|
|
178
178
|
"_deleted" TIMESTAMPTZ,
|
|
179
179
|
"_deletedBy" INTEGER,
|
|
180
180
|
${uniqueConstraint}
|
|
@@ -223,8 +223,8 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
223
223
|
"role_id" INTEGER NOT NULL,
|
|
224
224
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
225
225
|
"_createdBy" INTEGER NOT NULL,
|
|
226
|
-
"_updated" TIMESTAMPTZ
|
|
227
|
-
"_updatedBy" INTEGER
|
|
226
|
+
"_updated" TIMESTAMPTZ,
|
|
227
|
+
"_updatedBy" INTEGER,
|
|
228
228
|
"_deleted" TIMESTAMPTZ,
|
|
229
229
|
"_deletedBy" INTEGER,
|
|
230
230
|
CONSTRAINT "fk_user_roles_user" FOREIGN KEY("user_id") REFERENCES "users"("_id") ON DELETE CASCADE,
|
|
@@ -278,8 +278,8 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
278
278
|
"config" JSONB,
|
|
279
279
|
"_created" TIMESTAMPTZ NOT NULL,
|
|
280
280
|
"_createdBy" INTEGER NOT NULL,
|
|
281
|
-
"_updated" TIMESTAMPTZ
|
|
282
|
-
"_updatedBy" INTEGER
|
|
281
|
+
"_updated" TIMESTAMPTZ,
|
|
282
|
+
"_updatedBy" INTEGER,
|
|
283
283
|
"_deleted" TIMESTAMPTZ,
|
|
284
284
|
"_deletedBy" INTEGER,
|
|
285
285
|
CONSTRAINT "fk_authorizations_role" FOREIGN KEY("role_id") REFERENCES "roles"("_id") ON DELETE CASCADE,
|
|
@@ -297,9 +297,9 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
297
297
|
name: '00000000000011_data-meta-org',
|
|
298
298
|
up: async ({ context: pool }) => {
|
|
299
299
|
const result = await pool.query(`
|
|
300
|
-
INSERT INTO "organizations"("name", "code", "status", "is_meta_org", "_created", "_createdBy"
|
|
301
|
-
VALUES($1, $2, 1, true, NOW(), 0
|
|
302
|
-
RETURNING "_id", "name", "code", "status", "is_meta_org", "_created", "_createdBy"
|
|
300
|
+
INSERT INTO "organizations"("name", "code", "status", "is_meta_org", "_created", "_createdBy")
|
|
301
|
+
VALUES($1, $2, 1, true, NOW(), 0)
|
|
302
|
+
RETURNING "_id", "name", "code", "status", "is_meta_org", "_created", "_createdBy"
|
|
303
303
|
`, [dbConfig.multiTenant?.metaOrgName, dbConfig.multiTenant?.metaOrgCode]);
|
|
304
304
|
if (result.rowCount === 0) {
|
|
305
305
|
throw new Error('Failed to create meta organization');
|
|
@@ -330,20 +330,20 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
330
330
|
const client = await pool.connect();
|
|
331
331
|
try {
|
|
332
332
|
const personResult = isMultiTenant && orgId
|
|
333
|
-
? await client.query(`INSERT INTO "persons"("_orgId", "first_name", "last_name", "is_agent", "is_client", "is_employee", "_created", "_createdBy"
|
|
334
|
-
VALUES($1, 'Admin', 'User', false, false, false, NOW(), 0
|
|
333
|
+
? await client.query(`INSERT INTO "persons"("_orgId", "first_name", "last_name", "is_agent", "is_client", "is_employee", "_created", "_createdBy")
|
|
334
|
+
VALUES($1, 'Admin', 'User', false, false, false, NOW(), 0)
|
|
335
335
|
RETURNING "_id"`, [orgId])
|
|
336
|
-
: await client.query(`INSERT INTO "persons"("first_name", "last_name", "is_agent", "is_client", "is_employee", "_created", "_createdBy"
|
|
337
|
-
VALUES('Admin', 'User', false, false, false, NOW(), 0
|
|
336
|
+
: await client.query(`INSERT INTO "persons"("first_name", "last_name", "is_agent", "is_client", "is_employee", "_created", "_createdBy")
|
|
337
|
+
VALUES('Admin', 'User', false, false, false, NOW(), 0)
|
|
338
338
|
RETURNING "_id"`);
|
|
339
339
|
const personId = personResult.rows[0]._id;
|
|
340
340
|
if (isMultiTenant && orgId) {
|
|
341
|
-
await client.query(`INSERT INTO "users"("_orgId", "email", "display_name", "password", "person_id", "_created", "_createdBy"
|
|
342
|
-
VALUES($1, $2, 'Admin User', $3, $4, NOW(), 0
|
|
341
|
+
await client.query(`INSERT INTO "users"("_orgId", "email", "display_name", "password", "person_id", "_created", "_createdBy")
|
|
342
|
+
VALUES($1, $2, 'Admin User', $3, $4, NOW(), 0)`, [orgId, email, hashedPassword, personId]);
|
|
343
343
|
}
|
|
344
344
|
else {
|
|
345
|
-
await client.query(`INSERT INTO "users"("email", "display_name", "password", "person_id", "_created", "_createdBy"
|
|
346
|
-
VALUES($1, 'Admin User', $2, $3, NOW(), 0
|
|
345
|
+
await client.query(`INSERT INTO "users"("email", "display_name", "password", "person_id", "_created", "_createdBy")
|
|
346
|
+
VALUES($1, 'Admin User', $2, $3, NOW(), 0)`, [email, hashedPassword, personId]);
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
finally {
|
|
@@ -395,12 +395,12 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
395
395
|
const roleId = roleResult.rows[0]._id;
|
|
396
396
|
const userRoleResult = isMultiTenant
|
|
397
397
|
? await client.query(`
|
|
398
|
-
INSERT INTO "user_roles"("_orgId", "user_id", "role_id", "_created", "_createdBy"
|
|
399
|
-
VALUES($1, $2, $3, NOW(), 0
|
|
398
|
+
INSERT INTO "user_roles"("_orgId", "user_id", "role_id", "_created", "_createdBy")
|
|
399
|
+
VALUES($1, $2, $3, NOW(), 0)
|
|
400
400
|
`, [metaOrg._id, adminUserId, roleId])
|
|
401
401
|
: await client.query(`
|
|
402
|
-
INSERT INTO "user_roles"("user_id", "role_id", "_created", "_createdBy"
|
|
403
|
-
VALUES($1, $2, NOW(), 0
|
|
402
|
+
INSERT INTO "user_roles"("user_id", "role_id", "_created", "_createdBy")
|
|
403
|
+
VALUES($1, $2, NOW(), 0)
|
|
404
404
|
`, [adminUserId, roleId]);
|
|
405
405
|
if (userRoleResult.rowCount === 0) {
|
|
406
406
|
throw new Error('Failed to create user role');
|
|
@@ -424,16 +424,16 @@ export const getPostgresInitialSchema = (dbConfig) => {
|
|
|
424
424
|
? await client.query(`
|
|
425
425
|
INSERT INTO "authorizations"(
|
|
426
426
|
"_orgId", "role_id", "feature_id",
|
|
427
|
-
"_created", "_createdBy"
|
|
427
|
+
"_created", "_createdBy"
|
|
428
428
|
)
|
|
429
|
-
VALUES($1, $2, $3, NOW(), 0
|
|
429
|
+
VALUES($1, $2, $3, NOW(), 0)
|
|
430
430
|
`, [metaOrg._id, roleId, featureId])
|
|
431
431
|
: await client.query(`
|
|
432
432
|
INSERT INTO "authorizations"(
|
|
433
433
|
"role_id", "feature_id",
|
|
434
|
-
"_created", "_createdBy"
|
|
434
|
+
"_created", "_createdBy"
|
|
435
435
|
)
|
|
436
|
-
VALUES($1, $2, NOW(), 0
|
|
436
|
+
VALUES($1, $2, NOW(), 0)
|
|
437
437
|
`, [roleId, featureId]);
|
|
438
438
|
if (authorizationResult.rowCount === 0) {
|
|
439
439
|
throw new Error('Failed to create admin authorization');
|