File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -182,14 +182,39 @@ $(document).ready(() => {
182182 redrawCurrentView ( ) ;
183183 }
184184
185+ function schemaChange ( dbVersion , aboutCodeVersion ) {
186+ dbVersion = dbVersion . split ( '.' ) ;
187+ aboutCodeVersion = aboutCodeVersion . split ( '.' ) ;
188+
189+ if ( dbVersion [ 1 ] != aboutCodeVersion [ 1 ] ) {
190+ return true ;
191+ } else {
192+ return false ;
193+ }
194+ }
195+
185196 /** Creates the database and all View objects from a SQLite file */
186197 function loadDatabase ( fileName ) {
187198 // Create a new database when importing a json file
188199 aboutCodeDB = new AboutCodeDB ( {
189200 dbName : 'aboutcode_db' ,
190201 dbStorage : fileName
191202 } ) ;
192-
203+
204+ // Check that that the database schema matches current schema.
205+ aboutCodeDB . sync
206+ . then ( ( db ) => db . Header . findById ( 1 )
207+ . then ( ( header ) => {
208+ const dbVersion = header . aboutcode_manager_version ;
209+ if ( schemaChange ( dbVersion , aboutCodeVersion ) ) {
210+ dialog . showErrorBox (
211+ 'Old SQLite schema found at file: ' + fileName ,
212+ 'The SQLite schema has been updated since the last time you loaded this ' +
213+ 'file.\n\n' +
214+ 'Some features may not work correctly until you re-import the original' +
215+ 'ScanCode JSON file to create an updated SQLite database.' ) ;
216+ }
217+ } ) ) ;
193218 // Check that the database has the correct header information.
194219 aboutCodeDB . sync
195220 . then ( ( db ) => db . Header . findAll ( ) )
You can’t perform that action at this time.
0 commit comments