Prevent overwriting of base game cells is_base_game value

This fixes a bug that was causing cell data to not get written since
November 9th, 2023. When batch inserting cells while processing plugins,
I allowed overwriting cells that had `is_base_game = true`. Since I
always set `is_base_game = false` for cell upserts from plugins, this
was causing the base game cells to revert to `is_base_game = false`. All
it took was one mod to bundle `Skyrim.esm` for this to happen.

This broke writing cell data since `get_cell_data` depends on the
`is_base_game` value to find edits to the Skyrim base game cells.

To prevent this in the future, batch inserts when processing plugins is
no longer allowed to update cells which have `is_base_game = true`. The
only time we allow upserting these rows is when running the
`is_base_game` backfill which initially seeds the database with the base
game cells.
This commit is contained in:
2025-03-02 14:15:05 -05:00
parent a5135b30f4
commit a677325c4d
4 changed files with 62 additions and 31 deletions

View File

@@ -38,7 +38,7 @@ RUST_LOG=mod_mapper=debug
[`sqlx_cli`](https://github.com/launchbadge/sqlx/tree/master/sqlx-cli) with
`cargo install sqlx-cli --no-default-features --features postgres`
5. Run `sqlx migrate --source migrations run` which will run all the database migrations.
6. Get your personal Nexus API token from your profile settings and add it to
6. Get your personal Nexus API token from your profile settings and add it to
the `.env` file:
```
@@ -46,12 +46,12 @@ NEXUS_API_KEY=...
```
7. Build the release binary by running `cargo build --release`.
8. Run `./target/release/modmapper --backfill-is-game-cell` to pre-populate the
database with worlds and cells from the base game's Skyrim.esm. (This is so
that the base game cells can later be differentiated from cells in plugins that
also happen to be named Skyrim.esm and have cells that reference a world with
the same form ID as Tamriel.)
9. See `./target/release/modmapper -h` for further commands or run `./scripts/update.sh` to start populating the database with scraped mods and dumping the data to JSON files.
8. Run `./target/release/mod-mapper --backfill-is-base-game` to pre-populate the
database with worlds and cells from the base game's Skyrim.esm. (This is so
that the base game cells can later be differentiated from cells in plugins that
also happen to be named Skyrim.esm and have cells that reference a world with
the same form ID as Tamriel.)
9. See `./target/release/mod-mapper -h` for further commands or run `./scripts/update.sh` to start populating the database with scraped mods and dumping the data to JSON files.
## Sync and Backup Setup