File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed
Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 1+ module . exports = {
2+ async up ( db , client ) {
3+ /**
4+ * Use one transaction for all requests
5+ */
6+ const session = client . startSession ( ) ;
7+
8+ try {
9+ await session . withTransaction ( async ( ) => {
10+ const plansCollection = db . collection ( 'plans' ) ;
11+
12+ await plansCollection . updateMany (
13+ { } ,
14+ { $set : { monthlyChargeCurrency : 'RUB' } } // Set the default value for monthlyChargeCurrency
15+ ) ;
16+ } ) ;
17+
18+ } finally {
19+ await session . endSession ( ) ;
20+ }
21+ } ,
22+
23+ async down ( db , client ) {
24+ /**
25+ * Use one transaction for all requests
26+ */
27+ const session = client . startSession ( ) ;
28+
29+ try {
30+
31+ await session . withTransaction ( async ( ) => {
32+ const plansCollection = db . collection ( 'plans' ) ;
33+
34+ await plansCollection . updateMany (
35+ { } ,
36+ { $unset : { monthlyChargeCurrency : "" } } // Remove the monthlyChargeCurrency field
37+ ) ;
38+
39+ } ) ;
40+
41+ } finally {
42+ await session . endSession ( ) ;
43+ }
44+ }
45+ } ;
Original file line number Diff line number Diff line change @@ -17,10 +17,15 @@ export default class PlanModel extends AbstractModel<PlanDBScheme> implements Pl
1717 public name ! : string ;
1818
1919 /**
20- * Monthly charge for plan in dollars
20+ * Monthly charge for plan in currencry specified in `monthlyChargeCurrency`
2121 */
2222 public monthlyCharge ! : number ;
2323
24+ /**
25+ * Currency of `monthlyCharge`
26+ */
27+ public monthlyChargeCurrency ! : string ;
28+
2429 /**
2530 * Maximum amount of events available for plan
2631 */
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ export default gql`
2020 """
2121 monthlyCharge: Int!
2222
23+ """
24+ Currency of monthlyCharge
25+ """
26+ monthlyChargeCurrency: String!
27+
2328 """
2429 Events limit for plan
2530 """
You can’t perform that action at this time.
0 commit comments