Skip to content

Instantly share code, notes, and snippets.

@jimthedev
Last active January 7, 2017 17:29
Show Gist options
  • Save jimthedev/a6be98703d22765eb6442b9aa52b57ea to your computer and use it in GitHub Desktop.
Save jimthedev/a6be98703d22765eb6442b9aa52b57ea to your computer and use it in GitHub Desktop.
quick and dirty schema dirty checking for undeleteable websql databases
import myDatabaseSchema from './myDatabaseSchema';
import runDBMigrations from './myMigrations';
const schemaHash = hash(myDatabaseSchema);
const lastSchemaHash = localStorage.getItem('lastSchemaHash');
if(lastSchemaHash !== null && lastSchemaHash !== schemaHash) {
localStorage.setItem('lashSchemaHash', schemaHash);
console.log('schema changed! the world was deleted!');
runDBMigrations(lastSchemaHash, schemaHash);
}
myPouchRxdbOrOtherObjectDatabase.create(schemaHash);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment