mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
core: make item migration fall through all db versions
this was not exactly a bug but it can cause a lot of unintended behaviour. Previously, you'd have to manually specify which version the item migration should jump to. This was buggy and poorly designed. This change makes the item iterate over all the db migrations one by one automatically. For example: An item at version 5.2 will go through: - 5.3 - 5.4 - and so on
This commit is contained in:
committed by
Abdullah Atta
parent
9701a3d660
commit
c09715d053
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { migrations } from "../migrations";
|
||||
import { migrateItem } from "../migrations";
|
||||
|
||||
class Migrator {
|
||||
async migrate(db, collections, get, version) {
|
||||
@@ -40,8 +40,12 @@ class Migrator {
|
||||
item.type = "tiptap";
|
||||
}
|
||||
|
||||
const migrate = migrations[version][item.type || collection.type];
|
||||
if (migrate) item = await migrate(item, db);
|
||||
item = await migrateItem(
|
||||
item,
|
||||
version,
|
||||
item.type || collection.type,
|
||||
db
|
||||
);
|
||||
|
||||
if (collection.dbCollection.merge) {
|
||||
await collection.dbCollection.merge(item);
|
||||
|
||||
Reference in New Issue
Block a user