File tree Expand file tree Collapse file tree 3 files changed +66
-35
lines changed
modules/module-mongodb-storage/src/migrations/db/migrations Expand file tree Collapse file tree 3 files changed +66
-35
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @powersync/service-module-mongodb-storage ' : patch
3+ ' @powersync/service-core ' : patch
4+ ' @powersync/service-image ' : patch
5+ ---
6+
7+ [ MongoDB storage] Fix migration for indexes on connection_report_events.
Original file line number Diff line number Diff line change @@ -6,41 +6,7 @@ export const up: migrations.PowerSyncMigrationFunction = async (context) => {
66 const {
77 service_context : { configuration }
88 } = context ;
9- const db = storage . createPowerSyncMongo ( configuration . storage as MongoStorageConfig ) ;
10-
11- try {
12- await db . createConnectionReportingCollection ( ) ;
13-
14- await db . connection_report_events . createIndex (
15- {
16- connected_at : 1 ,
17- jwt_exp : 1 ,
18- disconnected_at : 1
19- } ,
20- { name : 'connection_list_index' }
21- ) ;
22-
23- await db . connection_report_events . createIndex (
24- {
25- user_id : 1
26- } ,
27- { name : 'connection_user_id_index' }
28- ) ;
29- await db . connection_report_events . createIndex (
30- {
31- client_id : 1
32- } ,
33- { name : 'connection_client_id_index' }
34- ) ;
35- await db . connection_report_events . createIndex (
36- {
37- sdk : 1
38- } ,
39- { name : 'connection_index' }
40- ) ;
41- } finally {
42- await db . client . close ( ) ;
43- }
9+ // No-op - moved to 1762790715147-connection-reporting2
4410} ;
4511
4612export const down : migrations . PowerSyncMigrationFunction = async ( context ) => {
Original file line number Diff line number Diff line change 1+ import { migrations } from '@powersync/service-core' ;
2+ import * as storage from '../../../storage/storage-index.js' ;
3+ import { MongoStorageConfig } from '../../../types/types.js' ;
4+
5+ export const up : migrations . PowerSyncMigrationFunction = async ( context ) => {
6+ const {
7+ service_context : { configuration }
8+ } = context ;
9+ const db = storage . createPowerSyncMongo ( configuration . storage as MongoStorageConfig ) ;
10+
11+ try {
12+ await db . createConnectionReportingCollection ( ) ;
13+
14+ await db . connection_report_events . createIndex (
15+ {
16+ connected_at : 1 ,
17+ jwt_exp : 1 ,
18+ disconnected_at : 1
19+ } ,
20+ { name : 'connection_list_index' }
21+ ) ;
22+
23+ await db . connection_report_events . createIndex (
24+ {
25+ user_id : 1
26+ } ,
27+ { name : 'connection_user_id_index' }
28+ ) ;
29+ await db . connection_report_events . createIndex (
30+ {
31+ client_id : 1
32+ } ,
33+ { name : 'connection_client_id_index' }
34+ ) ;
35+ await db . connection_report_events . createIndex (
36+ {
37+ sdk : 1
38+ } ,
39+ { name : 'connection_index' }
40+ ) ;
41+ } finally {
42+ await db . client . close ( ) ;
43+ }
44+ } ;
45+
46+ export const down : migrations . PowerSyncMigrationFunction = async ( context ) => {
47+ const {
48+ service_context : { configuration }
49+ } = context ;
50+
51+ const db = storage . createPowerSyncMongo ( configuration . storage as MongoStorageConfig ) ;
52+
53+ try {
54+ await db . db . dropCollection ( 'connection_report_events' ) ;
55+ } finally {
56+ await db . client . close ( ) ;
57+ }
58+ } ;
You can’t perform that action at this time.
0 commit comments