Code Monkey home page Code Monkey logo

Comments (8)

Aeristoka avatar Aeristoka commented on May 19, 2024

Additionally, it appears that this behavior is worse on a fresh install, as it will perform ALL data migrations (one after the other).

from tokenmagic.

Aeristoka avatar Aeristoka commented on May 19, 2024

Confirmed, brand new world, ONLY Token Magic FX enabled, this is the Token Magic part of settings.db:
image

It appears that:

  1. original tokenmagic.presets and tokenmagic-migration written (by migration.js?)
  2. 0.4.0/0.4.0b/0.4.1/0.4.3 migrations ALL applied

It appears that the migrations (except for the first one?) all get the LAST tokenmagic.presets, write that into settings.db, THEN writes the new one in. Confirmed with Diff.

from tokenmagic.

Aeristoka avatar Aeristoka commented on May 19, 2024

Issue in migration (in part) appears to be in this (and the other) parts of code for migration:

async function updatePresetsV043() {
    // Gets the CURRENT presets value
    var presets = game.settings.get("tokenmagic", "presets");
    
    if (!(presets == null)) {
        log('Migration 0.4.3 - Launching presets data migration...');
        
        try {
            // write the CURRENT presets back in again
            await game.settings.set("tokenmagic", "presets", presets);
            log('Migration 0.4.3 - updating template presets...');
            // write in the NEW presets?
            await Magic.importPresetLibraryFromPath("/modules/tokenmagic/import/TMFX-update-presets-v043.json", { overwrite: true });
            await game.settings.set("tokenmagic", "migration", DataVersion.V043);
            log('Migration 0.4.3 - Migration successful!');
        } catch (e) {
            error('Migration 0.4.3 - Migration failed.');
            error(e);
        }
    }
}

from tokenmagic.

dev7355608 avatar dev7355608 commented on May 19, 2024

Old entries in .db files are completely normal. That's just how the database (NeDB) works. You can read more about it here.

Migration on a fresh install seem to be intended, because it adds a bunch of presets. Some presets are only in the migration files but not in the default presets. It don't this causes any problems at the moment.

The migration version isn't part of the presets (it's part of the world), and it's not included in the exported file. Tokenmagic just assumes it gets the most recent version when you import presets. So if you import an older file, it won't migrate those presets. A workaround to force the migration would be to run game.settings.set("tokenmagic", "migration", VERSION) where VERSION is equal to the migration version the imported file was created with, e.g. "0.3.0", and then reload. If you don't know the correct version, try setting VERSION to ""; this should work, but it could override some modified presets though.

from tokenmagic.

Aeristoka avatar Aeristoka commented on May 19, 2024

Old entries in .db files are completely normal. That's just how the database (NeDB) works. You can read more about it here.

Migration on a fresh install seem to be intended, because it adds a bunch of presets. Some presets are only in the migration files but not in the default presets. It don't this causes any problems at the moment.

The migration version isn't part of the presets (it's part of the world), and it's not included in the exported file. Tokenmagic just assumes it gets the most recent version when you import presets. So if you import an older file, it won't migrate those presets. A workaround to force the migration would be to run game.settings.set("tokenmagic", "migration", VERSION) where VERSION is equal to the migration version the imported file was created with, e.g. "0.3.0", and then reload. If you don't know the correct version, try setting VERSION to ""; this should work, but it could override some modified presets though.

That still doesn't solve the issue of a brand new world getting every single Migration applied to it on initial module enablement. That's at best inefficient.

from tokenmagic.

dev7355608 avatar dev7355608 commented on May 19, 2024

The migration code starts with the 0.3.0 default presets and upgrades those to the newest version step by step in each new world. It's not really inefficient since it's just a one-time thing.

from tokenmagic.

Aeristoka avatar Aeristoka commented on May 19, 2024

The migration code starts with the 0.3.0 default presets and upgrades those to the newest version step by step in each new world. It's not really inefficient since it's just a one-time thing.

I'll differ with you there, but it makes sense. What I saw was a FoundryVTT user who got only the presets, and no migration info, and then never got the newer presets.

from tokenmagic.

Feu-Secret avatar Feu-Secret commented on May 19, 2024

@Aeristoka , thanks for your comments 😉
The migration submodule will be rewritten. I cannot give visibility at the moment.

from tokenmagic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.