Last active
January 7, 2017 17:29
-
-
Save jimthedev/a6be98703d22765eb6442b9aa52b57ea to your computer and use it in GitHub Desktop.
quick and dirty schema dirty checking for undeleteable websql databases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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