@@ -49,8 +49,8 @@ export interface DatabaseLoaderOptions {
4949 /** Organization ID for multi-tenant isolation */
5050 organizationId ?: string ;
5151
52- /** Environment ID — null = platform-global, set = env -scoped */
53- environmentId ?: string ;
52+ /** Project ID — null = platform-global, set = project -scoped */
53+ projectId ?: string ;
5454
5555 /** Enable history tracking (default: true) */
5656 trackHistory ?: boolean ;
@@ -83,7 +83,7 @@ export class DatabaseLoader implements MetadataLoader {
8383 private tableName : string ;
8484 private historyTableName : string ;
8585 private organizationId ?: string ;
86- private environmentId ?: string ;
86+ private projectId ?: string ;
8787 private trackHistory : boolean ;
8888 private schemaReady = false ;
8989 private historySchemaReady = false ;
@@ -99,7 +99,7 @@ export class DatabaseLoader implements MetadataLoader {
9999 this . tableName = options . tableName ?? 'sys_metadata' ;
100100 this . historyTableName = options . historyTableName ?? 'sys_metadata_history' ;
101101 this . organizationId = options . organizationId ;
102- this . environmentId = options . environmentId ;
102+ this . projectId = options . projectId ;
103103 this . trackHistory = options . trackHistory !== false ; // Default to true
104104 this . enableProjection = options . enableProjection !== false ; // Default to true
105105
@@ -109,7 +109,7 @@ export class DatabaseLoader implements MetadataLoader {
109109 driver : this . driver ,
110110 engine : this . engine ,
111111 organizationId : this . organizationId ,
112- environmentId : this . environmentId ,
112+ projectId : this . projectId ,
113113 } ) ;
114114 }
115115 }
@@ -214,7 +214,7 @@ export class DatabaseLoader implements MetadataLoader {
214214
215215 /**
216216 * Build base filter conditions for queries.
217- * Filters by organizationId when configured; env_id when environmentId is set,
217+ * Filters by organizationId when configured; project_id when projectId is set,
218218 * or null (platform-global) when not set.
219219 */
220220 private baseFilter ( type : string , name ?: string ) : Record < string , unknown > {
@@ -225,8 +225,8 @@ export class DatabaseLoader implements MetadataLoader {
225225 if ( this . organizationId ) {
226226 filter . organization_id = this . organizationId ;
227227 }
228- // When environmentId is set, scope to that env ; otherwise query platform-global (env_id = null).
229- filter . env_id = this . environmentId ?? null ;
228+ // When projectId is set, scope to that project ; otherwise query platform-global (project_id = null).
229+ filter . project_id = this . projectId ?? null ;
230230 return filter ;
231231 }
232232
@@ -283,7 +283,7 @@ export class DatabaseLoader implements MetadataLoader {
283283 recordedBy,
284284 recordedAt : now ,
285285 ...( this . organizationId ? { organizationId : this . organizationId } : { } ) ,
286- ...( this . environmentId !== undefined ? { environmentId : this . environmentId } : { } ) ,
286+ ...( this . projectId !== undefined ? { projectId : this . projectId } : { } ) ,
287287 } ;
288288
289289 try {
@@ -301,7 +301,7 @@ export class DatabaseLoader implements MetadataLoader {
301301 recorded_by : historyRecord . recordedBy ,
302302 recorded_at : historyRecord . recordedAt ,
303303 ...( this . organizationId ? { organization_id : this . organizationId } : { } ) ,
304- ...( this . environmentId !== undefined ? { env_id : this . environmentId } : { } ) ,
304+ ...( this . projectId !== undefined ? { project_id : this . projectId } : { } ) ,
305305 } ) ;
306306 } catch ( error ) {
307307 // Log error but don't fail the main operation
@@ -341,7 +341,7 @@ export class DatabaseLoader implements MetadataLoader {
341341 owner : row . owner as string | undefined ,
342342 state : ( row . state as MetadataRecord [ 'state' ] ) ?? 'active' ,
343343 organizationId : row . organization_id as string | undefined ,
344- environmentId : row . env_id as string | undefined ,
344+ projectId : row . project_id as string | undefined ,
345345 version : ( row . version as number ) ?? 1 ,
346346 checksum : row . checksum as string | undefined ,
347347 source : row . source as MetadataRecord [ 'source' ] ,
@@ -498,7 +498,7 @@ export class DatabaseLoader implements MetadataLoader {
498498 if ( this . organizationId ) {
499499 filter . organization_id = this . organizationId ;
500500 }
501- filter . env_id = this . environmentId ?? null ;
501+ filter . project_id = this . projectId ?? null ;
502502
503503 const row = await this . _findOne ( this . historyTableName , {
504504 where : filter ,
@@ -517,7 +517,7 @@ export class DatabaseLoader implements MetadataLoader {
517517 previousChecksum : row . previous_checksum as string | undefined ,
518518 changeNote : row . change_note as string | undefined ,
519519 organizationId : row . organization_id as string | undefined ,
520- environmentId : row . env_id as string | undefined ,
520+ projectId : row . project_id as string | undefined ,
521521 recordedBy : row . recorded_by as string | undefined ,
522522 recordedAt : row . recorded_at as string ,
523523 } ;
@@ -550,7 +550,7 @@ export class DatabaseLoader implements MetadataLoader {
550550 // Find the metadata record
551551 const filter : Record < string , unknown > = { type, name } ;
552552 if ( this . organizationId ) filter . organization_id = this . organizationId ;
553- filter . env_id = this . environmentId ?? null ;
553+ filter . project_id = this . projectId ?? null ;
554554
555555 const metadataRecord = await this . _findOne ( this . tableName , { where : filter } ) ;
556556 if ( ! metadataRecord ) {
@@ -562,7 +562,7 @@ export class DatabaseLoader implements MetadataLoader {
562562 metadata_id : metadataRecord . id ,
563563 } ;
564564 if ( this . organizationId ) historyFilter . organization_id = this . organizationId ;
565- historyFilter . env_id = this . environmentId ?? null ;
565+ historyFilter . project_id = this . projectId ?? null ;
566566 if ( options ?. operationType ) historyFilter . operation_type = options . operationType ;
567567 if ( options ?. since ) historyFilter . recorded_at = { $gte : options . since } ;
568568 if ( options ?. until ) {
@@ -609,7 +609,7 @@ export class DatabaseLoader implements MetadataLoader {
609609 previousChecksum : row . previous_checksum as string | undefined ,
610610 changeNote : row . change_note as string | undefined ,
611611 organizationId : row . organization_id as string | undefined ,
612- environmentId : row . env_id as string | undefined ,
612+ projectId : row . project_id as string | undefined ,
613613 recordedBy : row . recorded_by as string | undefined ,
614614 recordedAt : row . recorded_at as string ,
615615 } ;
@@ -752,7 +752,7 @@ export class DatabaseLoader implements MetadataLoader {
752752 version : 1 ,
753753 source : 'database' ,
754754 ...( this . organizationId ? { organization_id : this . organizationId } : { } ) ,
755- ...( this . environmentId !== undefined ? { env_id : this . environmentId } : { env_id : null } ) ,
755+ ...( this . projectId !== undefined ? { project_id : this . projectId } : { project_id : null } ) ,
756756 created_at : now ,
757757 updated_at : now ,
758758 } ) ;
0 commit comments