File tree Expand file tree Collapse file tree 1 file changed +7
-14
lines changed
packages/frontend/src/app/utils/localDb Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -127,26 +127,19 @@ export interface RSLocalDB extends DBSchema {
127
127
}
128
128
129
129
const connect = ( ) => {
130
- return openDB < RSLocalDB > ( `localDb` , 1 , {
130
+ const migrations = [ localDBMigration_1 , localDBMigration_2 ] ;
131
+
132
+ return openDB < RSLocalDB > ( `localDb` , migrations . length , {
131
133
upgrade : ( db , previousVersion , newVersion ) => {
132
134
console . log (
133
135
`Local DB upgrading from ${ previousVersion } to ${ newVersion } ` ,
134
136
) ;
135
137
136
138
try {
137
- // TODO: automate this
138
- switch ( previousVersion ) {
139
- case 0 : {
140
- localDBMigration_1 ( db ) ;
141
- localDBMigration_2 ( db ) ;
142
-
143
- return ;
144
- }
145
- case 1 : {
146
- localDBMigration_2 ( db ) ;
147
-
148
- return ;
149
- }
139
+ let i = previousVersion ;
140
+ while ( i < migrations . length ) {
141
+ migrations [ i ] ( db ) ;
142
+ i ++ ;
150
143
}
151
144
} catch ( e ) {
152
145
console . error ( e ) ;
You can’t perform that action at this time.
0 commit comments