mirror of
				https://github.com/hydralauncher/hydra.git
				synced 2025-03-09 15:40:26 +00:00 
			
		
		
		
	feat: refactor knex promises
This commit is contained in:
		
							parent
							
								
									158b878883
								
							
						
					
					
						commit
						88737cf80d
					
				
					 1 changed files with 13 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -53,6 +53,18 @@ if (process.defaultApp) {
 | 
			
		|||
  app.setAsDefaultProtocolClient(PROTOCOL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const runMigrations = async () => {
 | 
			
		||||
  await knexClient.migrate.list(migrationConfig).then((result) => {
 | 
			
		||||
    logger.log(
 | 
			
		||||
      "Migrations to run:",
 | 
			
		||||
      result[1].map((migration) => migration.name)
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  await knexClient.migrate.latest(migrationConfig);
 | 
			
		||||
  await knexClient.destroy();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// This method will be called when Electron has finished
 | 
			
		||||
// initialization and is ready to create browser windows.
 | 
			
		||||
// Some APIs can only be used after this event occurs.
 | 
			
		||||
| 
						 | 
				
			
			@ -64,15 +76,7 @@ app.whenReady().then(async () => {
 | 
			
		|||
    return net.fetch(url.pathToFileURL(decodeURI(filePath)).toString());
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  await knexClient.migrate.list(migrationConfig).then((result) => {
 | 
			
		||||
    logger.log(
 | 
			
		||||
      "Migrations to run:",
 | 
			
		||||
      result[1].map((migration) => migration.name)
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  await knexClient.migrate
 | 
			
		||||
    .latest(migrationConfig)
 | 
			
		||||
  await runMigrations()
 | 
			
		||||
    .then(() => {
 | 
			
		||||
      logger.log("Migrations executed successfully");
 | 
			
		||||
    })
 | 
			
		||||
| 
						 | 
				
			
			@ -80,8 +84,6 @@ app.whenReady().then(async () => {
 | 
			
		|||
      logger.log("Migrations failed to run:", err);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
  await knexClient.destroy();
 | 
			
		||||
 | 
			
		||||
  await dataSource.initialize();
 | 
			
		||||
 | 
			
		||||
  await import("./main");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue