@@ -238,14 +238,8 @@ afterAll(async () => {
238238 await mkdir ( dirname ( reportPath ) , { recursive : true } )
239239 await writeFile ( reportPath , JSON . stringify ( { checks } , null , 2 ) )
240240 for ( const f of fixtures ) {
241- await db
242- . delete ( workspaceFiles )
243- . where (
244- and ( eq ( workspaceFiles . entityType , 'project' ) , eq ( workspaceFiles . entityId , f . projectId ) )
245- )
246- await db
247- . delete ( folder )
248- . where ( and ( eq ( folder . entityType , 'project' ) , eq ( folder . entityId , f . projectId ) ) )
241+ await db . delete ( workspaceFiles ) . where ( eq ( workspaceFiles . projectId , f . projectId ) )
242+ await db . delete ( folder ) . where ( eq ( folder . projectId , f . projectId ) )
249243 await deleteWorkspaceFixture ( db , inArray ( workspace . id , f . workspaces ) )
250244 await db . delete ( organization ) . where ( eq ( organization . id , f . organizationId ) )
251245 await db . delete ( user ) . where ( inArray ( user . id , f . users ) )
@@ -403,8 +397,7 @@ describe('Project file authority at the database boundary', () => {
403397 const folderId = generateId ( )
404398 await db . insert ( folder ) . values ( {
405399 id : folderId ,
406- entityType : 'project' ,
407- entityId : f . projectId ,
400+ projectId : f . projectId ,
408401 resourceType : 'file' ,
409402 name : 'Docs' ,
410403 userId : f . ownerId ,
@@ -413,8 +406,7 @@ describe('Project file authority at the database boundary', () => {
413406 {
414407 id : rootFileId ,
415408 userId : f . ownerId ,
416- entityType : 'project' ,
417- entityId : f . projectId ,
409+ projectId : f . projectId ,
418410 context : 'project' ,
419411 key : `project/${ f . projectId } /${ rootFileId } ` ,
420412 originalName : 'a.md' ,
@@ -424,8 +416,7 @@ describe('Project file authority at the database boundary', () => {
424416 {
425417 id : nestedFileId ,
426418 userId : f . ownerId ,
427- entityType : 'project' ,
428- entityId : f . projectId ,
419+ projectId : f . projectId ,
429420 context : 'project' ,
430421 folderId,
431422 key : `project/${ f . projectId } /${ nestedFileId } ` ,
@@ -446,8 +437,7 @@ describe('Project file authority at the database boundary', () => {
446437 {
447438 id : generateId ( ) ,
448439 userId : other . ownerId ,
449- entityType : 'project' ,
450- entityId : other . projectId ,
440+ projectId : other . projectId ,
451441 context : 'project' ,
452442 key : `project/${ other . projectId } /a.md` ,
453443 originalName : 'a.md' ,
@@ -484,25 +474,22 @@ describe('Project file authority at the database boundary', () => {
484474 await db . insert ( folder ) . values ( [
485475 {
486476 id : docsId ,
487- entityType : 'project' ,
488- entityId : f . projectId ,
477+ projectId : f . projectId ,
489478 resourceType : 'file' ,
490479 name : 'Docs' ,
491480 userId : f . ownerId ,
492481 } ,
493482 {
494483 id : nestedId ,
495- entityType : 'project' ,
496- entityId : f . projectId ,
484+ projectId : f . projectId ,
497485 resourceType : 'file' ,
498486 name : 'Q3/Q4' ,
499487 parentId : docsId ,
500488 userId : f . ownerId ,
501489 } ,
502490 {
503491 id : siblingId ,
504- entityType : 'project' ,
505- entityId : f . projectId ,
492+ projectId : f . projectId ,
506493 resourceType : 'file' ,
507494 name : 'Elsewhere' ,
508495 userId : f . ownerId ,
@@ -513,8 +500,7 @@ describe('Project file authority at the database boundary', () => {
513500 fileIds . map ( ( id , index ) => ( {
514501 id,
515502 userId : f . ownerId ,
516- entityType : 'project' as const ,
517- entityId : f . projectId ,
503+ projectId : f . projectId ,
518504 context : 'project' ,
519505 folderId : [ null , docsId , nestedId , siblingId ] [ index ] ,
520506 key : `project/${ f . projectId } /${ id } ` ,
@@ -567,8 +553,7 @@ describe('Project file authority at the database boundary', () => {
567553 const folderId = generateId ( )
568554 await db . insert ( folder ) . values ( {
569555 id : folderId ,
570- entityType : 'project' ,
571- entityId : f . projectId ,
556+ projectId : f . projectId ,
572557 resourceType : 'file' ,
573558 name : 'Q3/Q4' ,
574559 userId : f . ownerId ,
@@ -580,8 +565,7 @@ describe('Project file authority at the database boundary', () => {
580565 {
581566 id : fileId ,
582567 userId : f . ownerId ,
583- entityType : 'project' ,
584- entityId : f . projectId ,
568+ projectId : f . projectId ,
585569 context : 'project' ,
586570 folderId,
587571 key : `project/${ f . projectId } /${ fileId } ` ,
@@ -592,8 +576,7 @@ describe('Project file authority at the database boundary', () => {
592576 {
593577 id : foreignId ,
594578 userId : other . ownerId ,
595- entityType : 'project' ,
596- entityId : other . projectId ,
579+ projectId : other . projectId ,
597580 context : 'project' ,
598581 key : `project/${ other . projectId } /${ foreignId } ` ,
599582 originalName : 'Architecture overview.md' ,
@@ -603,8 +586,7 @@ describe('Project file authority at the database boundary', () => {
603586 {
604587 id : archivedId ,
605588 userId : f . ownerId ,
606- entityType : 'project' ,
607- entityId : f . projectId ,
589+ projectId : f . projectId ,
608590 context : 'project' ,
609591 key : `project/${ f . projectId } /${ archivedId } ` ,
610592 originalName : 'old.md' ,
@@ -655,8 +637,7 @@ describe('Project file authority at the database boundary', () => {
655637 {
656638 id : fileId ,
657639 userId : f . ownerId ,
658- entityType : 'project' ,
659- entityId : f . projectId ,
640+ projectId : f . projectId ,
660641 context : 'project' ,
661642 key : `project/${ f . projectId } /${ fileId } ` ,
662643 originalName : 'architecture.md' ,
@@ -666,8 +647,7 @@ describe('Project file authority at the database boundary', () => {
666647 {
667648 id : foreignFileId ,
668649 userId : other . ownerId ,
669- entityType : 'project' ,
670- entityId : other . projectId ,
650+ projectId : other . projectId ,
671651 context : 'project' ,
672652 key : `project/${ other . projectId } /${ foreignFileId } ` ,
673653 originalName : 'architecture.md' ,
@@ -936,15 +916,13 @@ describe('Project file authority at the database boundary', () => {
936916 await db . insert ( folder ) . values ( {
937917 id : folderId ,
938918 userId : f . ownerId ,
939- entityType : 'project' ,
940- entityId : f . projectId ,
919+ projectId : f . projectId ,
941920 resourceType : 'file' ,
942921 name : 'Architecture' ,
943922 } )
944923 await db . insert ( workspaceFiles ) . values ( {
945924 id : fileId ,
946- entityType : 'project' ,
947- entityId : f . projectId ,
925+ projectId : f . projectId ,
948926 userId : f . ownerId ,
949927 context : 'project' ,
950928 folderId,
@@ -993,8 +971,7 @@ describe('Project file authority at the database boundary', () => {
993971 await db . insert ( workspaceFiles ) . values ( {
994972 id : fileId ,
995973 userId : f . ownerId ,
996- entityType : 'project' ,
997- entityId : f . projectId ,
974+ projectId : f . projectId ,
998975 context : 'project' ,
999976 key : `project/${ f . projectId } /${ fileId } ` ,
1000977 originalName : 'architecture.md' ,
@@ -1048,8 +1025,7 @@ describe('Project file authority at the database boundary', () => {
10481025 await db . insert ( workspaceFiles ) . values ( {
10491026 id : fileId ,
10501027 userId : f . ownerId ,
1051- entityType : 'project' ,
1052- entityId : f . projectId ,
1028+ projectId : f . projectId ,
10531029 context : 'project' ,
10541030 key : `project/${ f . projectId } /${ fileId } ` ,
10551031 originalName : 'transport.md' ,
0 commit comments