File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { AdminEdgeDBRepository } from './admin.edgedb.repository';
5
5
import { AdminEdgeDBService } from './admin.edgedb.service' ;
6
6
import { AdminRepository } from './admin.repository' ;
7
7
import { AdminService } from './admin.service' ;
8
+ import { NormalizeCreatorBaseNodeMigration } from './migrations/normalize-creator-base-node.migration' ;
8
9
import { NormalizeCreatorMigration } from './migrations/normalize-creator.migration' ;
9
10
10
11
@Module ( {
@@ -18,6 +19,7 @@ import { NormalizeCreatorMigration } from './migrations/normalize-creator.migrat
18
19
AdminEdgeDBRepository ,
19
20
) ,
20
21
NormalizeCreatorMigration ,
22
+ NormalizeCreatorBaseNodeMigration ,
21
23
] ,
22
24
} )
23
25
export class AdminModule { }
Original file line number Diff line number Diff line change
1
+ import { BaseMigration , Migration } from '~/core/database' ;
2
+
3
+ @Migration ( '2024-04-18T09:00:00' )
4
+ export class NormalizeCreatorBaseNodeMigration extends BaseMigration {
5
+ async up ( ) {
6
+ // Handle RootUser first specially.
7
+ // Since denormalized creator IDs for RootUser currently reference a non-existent user ID
8
+ await this . db . query ( ) . raw `
9
+ match (user:RootUser)
10
+ match (bn:BaseNode)
11
+ where bn.creator is not null and not exists { (:User { id: bn.creator }) }
12
+ create (bn)-[:creator { active: true, createdAt: bn.createdAt }]->(user)
13
+ set bn.creator = null
14
+ ` . executeAndLogStats ( ) ;
15
+
16
+ await this . db . query ( ) . raw `
17
+ match (bn:BaseNode)
18
+ where bn.creator is not null
19
+ match (user:User { id: bn.creator })
20
+ create (bn)-[:creator { active: true, createdAt: bn.createdAt }]->(user)
21
+ set bn.creator = null
22
+ ` . executeAndLogStats ( ) ;
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments