Commit 1205497 1 parent 3873a05 commit 1205497 Copy full SHA for 1205497
File tree 1 file changed +35
-21
lines changed
1 file changed +35
-21
lines changed Original file line number Diff line number Diff line change @@ -1267,27 +1267,41 @@ const rootMutations = {
1267
1267
} ) ;
1268
1268
}
1269
1269
1270
- const [ newOrganization ] = await r . knex ( "organization" ) . insert ( {
1271
- name,
1272
- uuid : uuidv4 ( )
1273
- } ) ;
1274
- await r . knex ( "user_organization" ) . insert ( {
1275
- role : "OWNER" ,
1276
- user_id : userId ,
1277
- organization_id : newOrganization . id
1278
- } ) ;
1279
- await r . knex ( "invite" ) . update ( {
1280
- id : inviteId ,
1281
- is_valid : false
1282
- } ) ;
1283
- await r . knex ( "tag" ) . insert ( {
1284
- organization_id : newOrganization . id ,
1285
- title : "Escalated" ,
1286
- description :
1287
- "Escalation is meant for situations where you have exhausted all available help resources and still do not know how to respond." ,
1288
- confirmation_steps : [ ] ,
1289
- is_assignable : false ,
1290
- is_system : true
1270
+ const newOrganization = await r . knex . transaction ( async trx => {
1271
+ const insertResult = await trx ( "organization" )
1272
+ . insert ( {
1273
+ name,
1274
+ uuid : uuidv4 ( )
1275
+ } )
1276
+ . returning ( "*" ) ;
1277
+
1278
+ const newOrganization = insertResult [ 0 ] ;
1279
+
1280
+ await trx ( "user_organization" ) . insert ( {
1281
+ role : "OWNER" ,
1282
+ user_id : userId ,
1283
+ organization_id : newOrganization . id
1284
+ } ) ;
1285
+
1286
+ await trx ( "invite" )
1287
+ . update ( {
1288
+ is_valid : false
1289
+ } )
1290
+ . where ( {
1291
+ id : parseInt ( inviteId )
1292
+ } ) ;
1293
+
1294
+ await trx ( "tag" ) . insert ( {
1295
+ organization_id : newOrganization . id ,
1296
+ title : "Escalated" ,
1297
+ description :
1298
+ "Escalation is meant for situations where you have exhausted all available help resources and still do not know how to respond." ,
1299
+ confirmation_steps : [ ] ,
1300
+ is_assignable : false ,
1301
+ is_system : true
1302
+ } ) ;
1303
+
1304
+ return newOrganization ;
1291
1305
} ) ;
1292
1306
1293
1307
return newOrganization ;
You can’t perform that action at this time.
0 commit comments