You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			36 lines
		
	
	
		
			846 B
		
	
	
	
		
			JavaScript
		
	
			
		
		
	
	
			36 lines
		
	
	
		
			846 B
		
	
	
	
		
			JavaScript
		
	
| /* global window, Whisper */
 | |
| 
 | |
| const Migrations = require('./migrations');
 | |
| 
 | |
| exports.getPlaceholderMigrations = () => {
 | |
|   const version = Migrations.getLatestVersion();
 | |
| 
 | |
|   return [
 | |
|     {
 | |
|       version,
 | |
|       migrate() {
 | |
|         throw new Error(
 | |
|           'Unexpected invocation of placeholder migration!' +
 | |
|             '\n\nMigrations must explicitly be run upon application startup instead' +
 | |
|             ' of implicitly via Backbone IndexedDB adapter at any time.'
 | |
|         );
 | |
|       },
 | |
|     },
 | |
|   ];
 | |
| };
 | |
| 
 | |
| exports.getCurrentVersion = () =>
 | |
|   new Promise((resolve, reject) => {
 | |
|     const request = window.indexedDB.open(Whisper.Database.id);
 | |
| 
 | |
|     request.onerror = reject;
 | |
|     request.onupgradeneeded = reject;
 | |
| 
 | |
|     request.onsuccess = () => {
 | |
|       const db = request.result;
 | |
|       const { version } = db;
 | |
| 
 | |
|       return resolve(version);
 | |
|     };
 | |
|   });
 |