@@ -318,8 +318,8 @@ export abstract class SqlProviderBase extends NoSqlProvider.DbProvider {
318318 const columnBasedIndices = _ . filter ( storeSchema . indexes , index =>
319319 ! indexUsesSeparateTable ( index , this . _supportsFTS3 ) ) ;
320320
321- const indexColumns = _ . map ( columnBasedIndices , index => 'nsp_i_' + index . name + ' TEXT' ) ;
322- fieldList = fieldList . concat ( indexColumns ) ;
321+ const indexColumnsNames = _ . map ( columnBasedIndices , index => 'nsp_i_' + index . name + ' TEXT' ) ;
322+ fieldList = fieldList . concat ( indexColumnsNames ) ;
323323 const tableMakerSql = 'CREATE TABLE ' + storeSchema . name + ' (' + fieldList . join ( ', ' ) + ')' ;
324324
325325 const currentIndexMetas = _ . filter ( indexMetadata , meta => meta . storeName === storeSchema . name ) ;
@@ -331,6 +331,8 @@ export abstract class SqlProviderBase extends NoSqlProvider.DbProvider {
331331 const [ newIndices , existingIndices ] = _ . partition ( storeSchema . indexes , index =>
332332 ! indexMetaDictionary [ getIndexIdentifier ( storeSchema , index ) ] ) ;
333333
334+ const existingIndexColumns = _ . intersection ( existingIndices , columnBasedIndices ) ;
335+
334336 // find indices in the meta that do not exist in the new schema
335337 const allRemovedIndexMetas = _ . filter ( currentIndexMetas , meta =>
336338 ! indexIdentifierDictionary [ meta . key ] ) ;
@@ -471,10 +473,10 @@ export abstract class SqlProviderBase extends NoSqlProvider.DbProvider {
471473 if ( doSqlInPlaceMigration ) {
472474 const sqlInPlaceMigrator = ( ) => {
473475 const columnsToCopy = [ 'nsp_pk' , 'nsp_data' ,
474- ..._ . map ( existingIndices , index => getIndexIdentifier ( storeSchema , index ) )
476+ ..._ . map ( existingIndexColumns , index => 'nsp_i_' + index . name )
475477 ] . join ( ', ' ) ;
476478
477- return trans . runQuery ( 'INSERT INTO ' + storeSchema . name + '(' + columnsToCopy + ')' +
479+ return trans . runQuery ( 'INSERT INTO ' + storeSchema . name + ' (' + columnsToCopy + ')' +
478480 ' SELECT ' + columnsToCopy +
479481 ' FROM temp_' + storeSchema . name ) ;
480482 } ;
0 commit comments