@loomcore/api 0.1.59 → 0.1.60
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.
|
@@ -5,14 +5,6 @@ import { AuthService, OrganizationService } from '../../../services/index.js';
|
|
|
5
5
|
export const getMongoInitialSchema = (config) => {
|
|
6
6
|
const migrations = [];
|
|
7
7
|
const isMultiTenant = config.app.isMultiTenant === true;
|
|
8
|
-
console.log('📋 Migration Config Diagnostic:');
|
|
9
|
-
console.log(' isMultiTenant:', isMultiTenant);
|
|
10
|
-
console.log(' config.app.metaOrgName:', config.app.metaOrgName ?? '(undefined)');
|
|
11
|
-
console.log(' config.app.metaOrgCode:', config.app.metaOrgCode ?? '(undefined)');
|
|
12
|
-
console.log(' config.auth?.adminUser?.email:', config.auth?.adminUser?.email ?? '(undefined)');
|
|
13
|
-
console.log(' config.auth?.adminUser?.password:', config.auth?.adminUser?.password ? '(set)' : '(undefined)');
|
|
14
|
-
console.log(' Will add meta-org migration:', isMultiTenant && !!config.app.metaOrgName && !!config.app.metaOrgCode);
|
|
15
|
-
console.log(' Will add admin-user migration:', !!config.auth?.adminUser?.email && !!config.auth?.adminUser?.password);
|
|
16
8
|
if (isMultiTenant) {
|
|
17
9
|
migrations.push({
|
|
18
10
|
name: '00000000000001_schema-organizations',
|
|
@@ -163,13 +155,14 @@ export const getMongoInitialSchema = (config) => {
|
|
|
163
155
|
}
|
|
164
156
|
const database = new MongoDBDatabase(db);
|
|
165
157
|
const authService = new AuthService(database);
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
'
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
158
|
+
if (!isSystemUserContextInitialized()) {
|
|
159
|
+
const errorMessage = isMultiTenant
|
|
160
|
+
? 'SystemUserContext has not been initialized. The meta-org migration (00000000000008_data-meta-org) should have run before this migration. ' +
|
|
161
|
+
'This migration only runs if config.app.metaOrgName and config.app.metaOrgCode are provided. ' +
|
|
162
|
+
'Please ensure both values are set in your config.'
|
|
163
|
+
: 'BUG: SystemUserContext has not been initialized. For non-multi-tenant setups, SystemUserContext should be initialized before migrations run.';
|
|
164
|
+
console.error('❌ Migration Error:', errorMessage);
|
|
165
|
+
throw new Error(errorMessage);
|
|
173
166
|
}
|
|
174
167
|
const systemUserContext = getSystemUserContext();
|
|
175
168
|
const _id = randomUUID().toString();
|
|
@@ -4,14 +4,6 @@ import { AuthService, OrganizationService } from '../../../services/index.js';
|
|
|
4
4
|
export const getPostgresInitialSchema = (config) => {
|
|
5
5
|
const migrations = [];
|
|
6
6
|
const isMultiTenant = config.app.isMultiTenant === true;
|
|
7
|
-
console.log('📋 Migration Config Diagnostic:');
|
|
8
|
-
console.log(' isMultiTenant:', isMultiTenant);
|
|
9
|
-
console.log(' config.app.metaOrgName:', config.app.metaOrgName ?? '(undefined)');
|
|
10
|
-
console.log(' config.app.metaOrgCode:', config.app.metaOrgCode ?? '(undefined)');
|
|
11
|
-
console.log(' config.auth?.adminUser?.email:', config.auth?.adminUser?.email ?? '(undefined)');
|
|
12
|
-
console.log(' config.auth?.adminUser?.password:', config.auth?.adminUser?.password ? '(set)' : '(undefined)');
|
|
13
|
-
console.log(' Will add meta-org migration:', isMultiTenant && !!config.app.metaOrgName && !!config.app.metaOrgCode);
|
|
14
|
-
console.log(' Will add admin-user migration:', !!config.auth?.adminUser?.email && !!config.auth?.adminUser?.password);
|
|
15
7
|
if (isMultiTenant) {
|
|
16
8
|
migrations.push({
|
|
17
9
|
name: '00000000000001_schema-organizations',
|
|
@@ -226,13 +218,14 @@ export const getPostgresInitialSchema = (config) => {
|
|
|
226
218
|
try {
|
|
227
219
|
const database = new PostgresDatabase(client);
|
|
228
220
|
const authService = new AuthService(database);
|
|
229
|
-
if (
|
|
230
|
-
|
|
231
|
-
'
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
221
|
+
if (!isSystemUserContextInitialized()) {
|
|
222
|
+
const errorMessage = isMultiTenant
|
|
223
|
+
? 'SystemUserContext has not been initialized. The meta-org migration (00000000000008_data-meta-org) should have run before this migration. ' +
|
|
224
|
+
'This migration only runs if config.app.metaOrgName and config.app.metaOrgCode are provided. ' +
|
|
225
|
+
'Please ensure both values are set in your config.'
|
|
226
|
+
: 'BUG: SystemUserContext has not been initialized. For non-multi-tenant setups, SystemUserContext should be initialized before migrations run.';
|
|
227
|
+
console.error('❌ Migration Error:', errorMessage);
|
|
228
|
+
throw new Error(errorMessage);
|
|
236
229
|
}
|
|
237
230
|
const systemUserContext = getSystemUserContext();
|
|
238
231
|
const userData = {
|