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 { NormalizeCreatorMigration } from './migrations/normalize-creator.migration' ;
8
9
9
10
@Module ( {
10
11
imports : [ AuthorizationModule ] ,
@@ -16,6 +17,7 @@ import { AdminService } from './admin.service';
16
17
// and each will only use their own.
17
18
AdminEdgeDBRepository ,
18
19
) ,
20
+ NormalizeCreatorMigration ,
19
21
] ,
20
22
} )
21
23
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-16T19:00:00' )
4
+ export class NormalizeCreatorMigration 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)-[r:creator { active: true }]->(oldCreatorProp:Property)
11
+ where not exists { (:User { id: oldCreatorProp.value }) }
12
+ create (bn)-[:creator { active: true, createdAt: r.createdAt }]->(user)
13
+ detach delete oldCreatorProp
14
+ ` . executeAndLogStats ( ) ;
15
+
16
+ await this . db . query ( ) . raw `
17
+ match (bn)-[r:creator { active: true }]->(oldCreatorProp:Property)
18
+ with bn, r, oldCreatorProp
19
+ match (user:User { id: oldCreatorProp.value })
20
+ create (bn)-[:creator { active: true, createdAt: r.createdAt }]->(user)
21
+ detach delete oldCreatorProp
22
+ ` . executeAndLogStats ( ) ;
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments