@@ -2,13 +2,13 @@ import { DatabaseSettingsFactoryContract } from "..";
22import { Version } from "./../model/version-model" ;
33import { forkJoin , from , Observable , Observer } from "rxjs" ;
44import { Injectable , Injector , Optional } from "@angular/core" ;
5- import { DatabaseTransaction , Ddl } from "database-builder" ;
5+ import { Ddl , DatabaseObject } from "database-builder" ;
66import { DatabaseMigrationContract } from "./database-migration-contract" ;
77import { DatabaseMigrationBase } from "../utils/database-migration-base" ;
88import { DatabaseResettableContract } from "./database-resettable-contract" ;
99
1010@Injectable ( )
11- export class DatabaseMigration extends DatabaseMigrationBase implements DatabaseResettableContract {
11+ export class DatabaseMigration extends DatabaseMigrationBase implements DatabaseResettableContract {
1212
1313 private _settings : DatabaseSettingsFactoryContract ;
1414
@@ -20,7 +20,7 @@ export class DatabaseMigration extends DatabaseMigrationBase implements Database
2020 this . _settings = _injector . get ( DatabaseSettingsFactoryContract ) ;
2121 }
2222
23- public reset ( transation : DatabaseTransaction ) : Observable < any > {
23+ public reset ( database : DatabaseObject ) : Observable < any > {
2424
2525 // tslint:disable-next-line:no-console
2626 console . info ( "database reset" ) ;
@@ -30,7 +30,7 @@ export class DatabaseMigration extends DatabaseMigrationBase implements Database
3030 const mappers = this . _settings . mapper ( this . _injector ) ;
3131
3232 // remove dados offline da versão anterior, pois o formato dos dados foi alterado de uma versão para a outra
33- const ddl = new Ddl ( transation , mappers , true ) ;
33+ const ddl = new Ddl ( database , mappers , true ) ;
3434 mappers . forEachMapper ( ( value , key ) => {
3535 if ( ! value . readOnly ) {
3636 observablesWait . push ( from ( ddl . drop ( value . newable ) . execute ( ) ) ) ;
@@ -41,14 +41,14 @@ export class DatabaseMigration extends DatabaseMigrationBase implements Database
4141 return forkJoin ( observablesWait ) ;
4242 }
4343
44- protected migrationExecute ( transation : DatabaseTransaction , version : Version ) : Promise < boolean > {
44+ protected migrationExecute ( database : DatabaseObject , version : Version ) : Promise < boolean > {
4545 return new Promise < boolean > ( ( resolve , reject ) => {
4646
4747 let observablesNested : Array < Observable < any > > = [ ] ;
4848 if ( this . _databaseMigrationContract ) {
4949 const toObservables = this . _databaseMigrationContract . to (
50- version ,
51- transation ,
50+ version ,
51+ database ,
5252 this . _settings . mapper ( this . _injector ) ,
5353 this
5454 ) ;
@@ -58,23 +58,24 @@ export class DatabaseMigration extends DatabaseMigrationBase implements Database
5858 }
5959
6060 if ( observablesNested . length === 0 && version . oldVersion < 1 ) {
61- observablesNested . push ( this . reset ( transation ) ) ;
61+ observablesNested . push ( this . reset ( database ) ) ;
6262 }
6363
64- this . callNested ( observablesNested , 0 ) . subscribe ( result => {
65- resolve ( result ) ;
66- } , error => reject ( error ) ) ;
64+ this . callNested ( observablesNested , 0 )
65+ . subscribe ( ( result : boolean | PromiseLike < boolean > ) => {
66+ resolve ( result ) ;
67+ } , ( error : any ) => reject ( error ) ) ;
6768 } ) ;
6869 }
6970
7071 private callNested ( observablesNested : Array < Observable < any > > , nextIndex : number ) : Observable < boolean > {
7172 return Observable . create ( ( observer : Observer < boolean > ) => {
7273 if ( observablesNested . length > nextIndex ) {
73- observablesNested [ nextIndex ] . subscribe ( result => {
74- this . callNested ( observablesNested , ++ nextIndex ) . subscribe ( _ => {
74+ observablesNested [ nextIndex ] . subscribe ( ( result : any ) => {
75+ this . callNested ( observablesNested , ++ nextIndex ) . subscribe ( ( _ : any ) => {
7576 observer . next ( true ) ;
7677 observer . complete ( ) ;
77- } , error => {
78+ } , ( error : any ) => {
7879 observer . error ( error ) ;
7980 observer . complete ( ) ;
8081 } ) ;
0 commit comments