1+ /// <reference path="../pb_data/types.d.ts" />
2+ migrate ( ( app ) => {
3+ const collection = app . findCollectionByNameOrId ( "pbc_3527180448" ) ;
4+
5+ // add payment intent field
6+ collection . fields . addAt ( collection . fields . length , new Field ( {
7+ "id" : "stripe_payment_intent" ,
8+ "name" : "stripe_payment_intent_id" ,
9+ "type" : "text" ,
10+ "required" : false ,
11+ "presentable" : false ,
12+ "system" : false ,
13+ "hidden" : false ,
14+ "autogeneratePattern" : "" ,
15+ "max" : 0 ,
16+ "min" : 0 ,
17+ "pattern" : "" ,
18+ "primaryKey" : false
19+ } ) ) ;
20+
21+ // add payment method relation
22+ collection . fields . addAt ( collection . fields . length , new Field ( {
23+ "id" : "stripe_payment_method" ,
24+ "name" : "payment_method" ,
25+ "type" : "relation" ,
26+ "required" : false ,
27+ "presentable" : false ,
28+ "system" : false ,
29+ "hidden" : false ,
30+ "collectionId" : "payment_methods" ,
31+ "cascadeDelete" : false ,
32+ "maxSelect" : 1 ,
33+ "minSelect" : 0
34+ } ) ) ;
35+
36+ // add payment status field
37+ collection . fields . addAt ( collection . fields . length , new Field ( {
38+ "id" : "stripe_payment_status" ,
39+ "name" : "payment_status" ,
40+ "type" : "select" ,
41+ "required" : true ,
42+ "presentable" : false ,
43+ "system" : false ,
44+ "hidden" : false ,
45+ "values" : [ "pending" , "processing" , "succeeded" , "failed" , "refunded" ] ,
46+ "maxSelect" : 1
47+ } ) ) ;
48+
49+ return app . save ( collection ) ;
50+ } , ( app ) => {
51+ const collection = app . findCollectionByNameOrId ( "pbc_3527180448" ) ;
52+
53+ // remove fields
54+ collection . fields . removeById ( "stripe_payment_intent" ) ;
55+ collection . fields . removeById ( "stripe_payment_method" ) ;
56+ collection . fields . removeById ( "stripe_payment_status" ) ;
57+
58+ return app . save ( collection ) ;
59+ } )
0 commit comments