Closed Kalabasa closed 2 years ago
Can you provide reproduce example?
browser:
(async () => {
const { kvsEnvStorage } = await import("https://cdn.skypack.dev/@kvs/env@2.1.2");
const storage = await kvsEnvStorage({
name: "database-name",
version: 2,
async upgrade({ kvs, oldVersion, newVersion }) {
console.log({
oldVersion, // 0
newVersion // 2
});
}
});
})();
node:
It is reproducible it in your node replit example. Check ~/kvs-env-new-version/.cache/kvs-node-localstorage/database-name.__.__kvs_version__
. Version is always 1
, regardless of the version in the app.
Another example: https://replit.com/@Kalabasa-/kvs-env-new-version#index.js
https://github.com/azu/kvs/blob/7b4953ee016bae296d6f8ad5847803de06322823/packages/storage/src/storage.ts#L120-L131 Maybe, we need to write version to storage.
TODO
Version is always 1, no matter what you put in. It also causes the
upgrade
function to be called every time.