pkg/casc/cdn: build list over HTTPS from <region>.version.battle.net, archive index scan, HTTP range reads, cache of indexes and loose files. Every downloaded file is checked (BLTE header and block MD5s vs its encoding key) before caching; bounded responses; next-server retry on bad bodies.
pkg/dataset: shared table loader (Load, streaming OnTable or Result.Tables), used by export and by other callers.
pkg/defs.Generate works on any storage.
CLI: export --cdn (writes wowf-<version>-cdn.sqlite, leaves current.sqlite on the local export) and --hotfixes FILE; _meta.source.
internal/export and pkg/dataset stay network-free (TestNoNetworkDeps).
Checks
gofmt, go vet, staticcheck, go test -race ./..., fuzz smoke runs.
Real data: local export identical to before (full-database identity diff); CDN export identical to the local one (1161 tables); real CDN test: 308 MB, ~14 s cold, peak 541 MiB.
| `--force` | Export even when the database is already up to date |
35
+
| `--cdn` | Export the latest build from the Blizzard CDN instead of a local install (`--dir` is ignored) |
36
+
| `--hotfixes FILE` | `DBCache.bin` to apply; default: the install's, none with `--cdn`. On a local export it implies `--force` |
34
37
| `-v`, `--verbose` | Debug logging |
35
38
36
39
A flag always wins over its environment variable.
37
40
38
-
Each export writes `wowf-<version>.sqlite` and points the `current.sqlite` symlink at it.
41
+
Each local export writes `wowf-<version>.sqlite` and points the `current.sqlite` symlink at it. A `--cdn` export writes `wowf-<version>-cdn.sqlite` and leaves `current.sqlite` alone: it always tracks the local install.
42
+
43
+
### CDN source
44
+
45
+
`export --cdn` needs no game install: it reads the latest `wowf` build from Blizzard's public CDN (build list over HTTPS from `<region>.version.battle.net`). The first run downloads about 300 MB (encoding, root, archive indexes, the DB2 files); indexes and loose files are cached in `$XDG_CACHE_HOME/forever-db/cdn`, so later runs of the same build download a few MB. Hotfixes are not on the CDN: without `--hotfixes FILE` the export has none (`dbcache_status``missing`).
46
+
47
+
`scripts/compare-exports.sh A B` compares the craft tables of two exports (row counts and `EXCEPT` both ways).
39
48
40
49
### Definitions
41
50
42
-
`export` never uses the network. The table definitions and encryption keys for the Forever client ship inside the binary as a small snapshot.
51
+
`export` uses the network only with `--cdn`. The table definitions and encryption keys for the Forever client ship inside the binary as a small snapshot.
43
52
44
-
After a game patch, `export` may report tables without a definition (status `no_definition`) and suggests `forever-db defs update`. That command downloads WoWDBDefs and TACTKeys (cached and revalidated in `$XDG_CACHE_HOME/forever-db`), reads the installed client, and writes `<data dir>/defs.json.gz`, which overrides the embedded snapshot. By default the new definitions are merged with the current ones: the snapshot in use (`<data dir>/defs.json.gz`, else the embedded one), or, with `--output FILE` (written there instead), that file if it exists, else the embedded snapshot. `--fresh` starts from scratch, `--offline` uses the download cache only. `defs update` is the only command that uses the network.
53
+
After a game patch, `export` may report tables without a definition (status `no_definition`) and suggests `forever-db defs update`. That command downloads WoWDBDefs and TACTKeys (cached and revalidated in `$XDG_CACHE_HOME/forever-db`), reads the installed client, and writes `<data dir>/defs.json.gz`, which overrides the embedded snapshot. By default the new definitions are merged with the current ones: the snapshot in use (`<data dir>/defs.json.gz`, else the embedded one), or, with `--output FILE` (written there instead), that file if it exists, else the embedded snapshot. `--fresh` starts from scratch, `--offline` uses the download cache only. Apart from `export --cdn`, `defs update` is the only command that uses the network.
45
54
46
55
`forever-db defs show` prints which snapshot is in use (`embedded` or `local`), its builds, WoWDBDefs commit, generation time, table, layout and key counts, and an attribution line for the data sources (`attribution` object with `--json`).
47
56
48
-
Hotfixes change after a patch or a game session. `forever-db status` reports `up to date`, `stale` (with the reasons: `build_changed`, `hotfixes_changed`, `schema_changed`, `defs_changed` when the definitions snapshot in use differs from the one of the export) or `never exported`; run `export` again when it is stale.
57
+
Hotfixes change after a patch or a game session. `forever-db status` reports `up to date`, `stale` (with the reasons: `build_changed`, `hotfixes_changed`, `schema_changed`, `defs_changed` when the definitions snapshot in use differs from the one of the export, `source_changed` if `current.sqlite` points at a non-local export) or `never exported`; run `export` again when it is stale.
49
58
50
59
Exit codes: 0 success (including per-table failures, listed in the summary and `_tables`), 1 fatal error. Use `status --json` (`state`) and `_tables.status` in scripts.
51
60
52
61
## Database layout
53
62
54
63
- **One table per DB2 table**, named like the DB2 table (`SpellReagents`, `ItemSparse`, …). Columns follow the WoWDBDefs definition; arrays become `Name_0`, `Name_1`, … The record ID is the `INTEGER PRIMARY KEY`.
55
-
- **`_meta`**: key/value pairs: schema version, tool version, build version and key, locale, export time, DBCache hash and status (`applied`, `missing`, `invalid`, `build_mismatch`), definitions snapshot origin (`embedded` or `local`), its WoWDBDefs commit, generation time and SHA-256, table counts.
64
+
- **`_meta`**: key/value pairs: schema version, tool version, source (`local` or `cdn`), build version and key (the build config hash with `--cdn`), locale, export time, DBCache hash and status (`applied`, `missing`, `invalid`, `build_mismatch`), definitions snapshot origin (`embedded` or `local`), its WoWDBDefs commit, generation time and SHA-256, table counts.
56
65
- **`_tables`**: one row per table: `status` (`ok`, `absent`, `no_definition`, `failed`), error message, base row count, hotfix counts (upserts, deletes, reverts, errors), skipped rows and sections.
57
66
- **`_columns`**: one row per SQL column: type (`int`, `uint`, `float`, `string`), bit size, array index, and `ref_table` / `ref_column` for columns that reference another table. Use these to find joins.
58
67
- **`_hotfixes`**: every hotfix entry of a known table with the action taken (`upsert`, `delete`, `revert`, `ignored`, `error`).
@@ -95,7 +104,7 @@ WHERE ie."TriggerType" = 6 AND ie."SpellID" = ?;
95
104
| Variable | Points to |
96
105
|---|---|
97
106
| `FOREVER_DB_TEST_WOW_DIR` | A WoW Forever install (folder with `.build.info`) |
98
-
| `FOREVER_DB_TEST_DEFS` | A definitions snapshot (`defs.json.gz`), e.g. `internal/defs/data/forever.json.gz` |
107
+
| `FOREVER_DB_TEST_DEFS` | A definitions snapshot (`defs.json.gz`), e.g. `pkg/defs/data/forever.json.gz` |
99
108
| `FOREVER_DB_TEST_DBD_DIR` | A WoWDBDefs `definitions/` folder |
100
109
| `FOREVER_DB_TEST_MANIFEST` | A WoWDBDefs `manifest.json` |
101
110
| `FOREVER_DB_TEST_TACTKEYS` | A TACTKeys `WoW.txt` file |
@@ -107,7 +116,7 @@ WHERE ie."TriggerType" = 6 AND ie."SpellID" = ?;
The definitions snapshot (embedded, or written by `defs update`) is derived from these projects and is licensed under CC BY-SA 4.0; see `internal/defs/data/README.md`. The CASC, BLTE and WDC5 readers follow DBCD and TACTSharp (MIT); see `NOTICE`.
119
+
The definitions snapshot (embedded, or written by `defs update`) is derived from these projects and is licensed under CC BY-SA 4.0; see `pkg/defs/data/README.md`. The CASC, BLTE and WDC5 readers follow DBCD and TACTSharp (MIT); see `NOTICE`.
111
120
112
121
Copyright (C) 2026 bnema. SPDX-License-Identifier: AGPL-3.0-or-later. The project code is licensed under the GNU Affero General Public License v3.0 or later (see `LICENSE`).
113
122
@@ -5,7 +5,7 @@ forever-db exports the game data of a local World of Warcraft: Forever client in
5
## Install
5
## Install
6
6
7
```sh
7
```sh
8
-
go install github.com/bnema/forever-db@latest
8
+
go install bnema.dev/forever-db@latest
9
```
9
```
10
10
11
Or from a checkout:
11
Or from a checkout:
@@ -17,7 +17,8 @@ make build # produces build/forever-db
| `--force` | Export even when the database is already up to date |
34
| `--force` | Export even when the database is already up to date |
35
+
| `--cdn` | Export the latest build from the Blizzard CDN instead of a local install (`--dir` is ignored) |
36
+
| `--hotfixes FILE` | `DBCache.bin` to apply; default: the install's, none with `--cdn`. On a local export it implies `--force` |
34
| `-v`, `--verbose` | Debug logging |
37
| `-v`, `--verbose` | Debug logging |
35
38
36
A flag always wins over its environment variable.
39
A flag always wins over its environment variable.
37
40
38
-
Each export writes `wowf-<version>.sqlite` and points the `current.sqlite` symlink at it.
41
+
Each local export writes `wowf-<version>.sqlite` and points the `current.sqlite` symlink at it. A `--cdn` export writes `wowf-<version>-cdn.sqlite` and leaves `current.sqlite` alone: it always tracks the local install.
42
+
43
+
### CDN source
44
+
45
+
`export --cdn` needs no game install: it reads the latest `wowf` build from Blizzard's public CDN (build list over HTTPS from `<region>.version.battle.net`). The first run downloads about 300 MB (encoding, root, archive indexes, the DB2 files); indexes and loose files are cached in `$XDG_CACHE_HOME/forever-db/cdn`, so later runs of the same build download a few MB. Hotfixes are not on the CDN: without `--hotfixes FILE` the export has none (`dbcache_status``missing`).
46
+
47
+
`scripts/compare-exports.sh A B` compares the craft tables of two exports (row counts and `EXCEPT` both ways).
39
48
40
### Definitions
49
### Definitions
41
50
42
-
`export` never uses the network. The table definitions and encryption keys for the Forever client ship inside the binary as a small snapshot.
51
+
`export` uses the network only with `--cdn`. The table definitions and encryption keys for the Forever client ship inside the binary as a small snapshot.
43
52
44
-
After a game patch, `export` may report tables without a definition (status `no_definition`) and suggests `forever-db defs update`. That command downloads WoWDBDefs and TACTKeys (cached and revalidated in `$XDG_CACHE_HOME/forever-db`), reads the installed client, and writes `<data dir>/defs.json.gz`, which overrides the embedded snapshot. By default the new definitions are merged with the current ones: the snapshot in use (`<data dir>/defs.json.gz`, else the embedded one), or, with `--output FILE` (written there instead), that file if it exists, else the embedded snapshot. `--fresh` starts from scratch, `--offline` uses the download cache only. `defs update` is the only command that uses the network.
53
+
After a game patch, `export` may report tables without a definition (status `no_definition`) and suggests `forever-db defs update`. That command downloads WoWDBDefs and TACTKeys (cached and revalidated in `$XDG_CACHE_HOME/forever-db`), reads the installed client, and writes `<data dir>/defs.json.gz`, which overrides the embedded snapshot. By default the new definitions are merged with the current ones: the snapshot in use (`<data dir>/defs.json.gz`, else the embedded one), or, with `--output FILE` (written there instead), that file if it exists, else the embedded snapshot. `--fresh` starts from scratch, `--offline` uses the download cache only. Apart from `export --cdn`, `defs update` is the only command that uses the network.
45
54
46
`forever-db defs show` prints which snapshot is in use (`embedded` or `local`), its builds, WoWDBDefs commit, generation time, table, layout and key counts, and an attribution line for the data sources (`attribution` object with `--json`).
55
`forever-db defs show` prints which snapshot is in use (`embedded` or `local`), its builds, WoWDBDefs commit, generation time, table, layout and key counts, and an attribution line for the data sources (`attribution` object with `--json`).
47
56
48
-
Hotfixes change after a patch or a game session. `forever-db status` reports `up to date`, `stale` (with the reasons: `build_changed`, `hotfixes_changed`, `schema_changed`, `defs_changed` when the definitions snapshot in use differs from the one of the export) or `never exported`; run `export` again when it is stale.
57
+
Hotfixes change after a patch or a game session. `forever-db status` reports `up to date`, `stale` (with the reasons: `build_changed`, `hotfixes_changed`, `schema_changed`, `defs_changed` when the definitions snapshot in use differs from the one of the export, `source_changed` if `current.sqlite` points at a non-local export) or `never exported`; run `export` again when it is stale.
49
58
50
Exit codes: 0 success (including per-table failures, listed in the summary and `_tables`), 1 fatal error. Use `status --json` (`state`) and `_tables.status` in scripts.
59
Exit codes: 0 success (including per-table failures, listed in the summary and `_tables`), 1 fatal error. Use `status --json` (`state`) and `_tables.status` in scripts.
51
60
52
## Database layout
61
## Database layout
53
62
54
- **One table per DB2 table**, named like the DB2 table (`SpellReagents`, `ItemSparse`, …). Columns follow the WoWDBDefs definition; arrays become `Name_0`, `Name_1`, … The record ID is the `INTEGER PRIMARY KEY`.
63
- **One table per DB2 table**, named like the DB2 table (`SpellReagents`, `ItemSparse`, …). Columns follow the WoWDBDefs definition; arrays become `Name_0`, `Name_1`, … The record ID is the `INTEGER PRIMARY KEY`.
55
-
- **`_meta`**: key/value pairs: schema version, tool version, build version and key, locale, export time, DBCache hash and status (`applied`, `missing`, `invalid`, `build_mismatch`), definitions snapshot origin (`embedded` or `local`), its WoWDBDefs commit, generation time and SHA-256, table counts.
64
+
- **`_meta`**: key/value pairs: schema version, tool version, source (`local` or `cdn`), build version and key (the build config hash with `--cdn`), locale, export time, DBCache hash and status (`applied`, `missing`, `invalid`, `build_mismatch`), definitions snapshot origin (`embedded` or `local`), its WoWDBDefs commit, generation time and SHA-256, table counts.
56
- **`_tables`**: one row per table: `status` (`ok`, `absent`, `no_definition`, `failed`), error message, base row count, hotfix counts (upserts, deletes, reverts, errors), skipped rows and sections.
65
- **`_tables`**: one row per table: `status` (`ok`, `absent`, `no_definition`, `failed`), error message, base row count, hotfix counts (upserts, deletes, reverts, errors), skipped rows and sections.
57
- **`_columns`**: one row per SQL column: type (`int`, `uint`, `float`, `string`), bit size, array index, and `ref_table` / `ref_column` for columns that reference another table. Use these to find joins.
66
- **`_columns`**: one row per SQL column: type (`int`, `uint`, `float`, `string`), bit size, array index, and `ref_table` / `ref_column` for columns that reference another table. Use these to find joins.
58
- **`_hotfixes`**: every hotfix entry of a known table with the action taken (`upsert`, `delete`, `revert`, `ignored`, `error`).
67
- **`_hotfixes`**: every hotfix entry of a known table with the action taken (`upsert`, `delete`, `revert`, `ignored`, `error`).
@@ -95,7 +104,7 @@ WHERE ie."TriggerType" = 6 AND ie."SpellID" = ?;
95
| Variable | Points to |
104
| Variable | Points to |
96
|---|---|
105
|---|---|
97
| `FOREVER_DB_TEST_WOW_DIR` | A WoW Forever install (folder with `.build.info`) |
106
| `FOREVER_DB_TEST_WOW_DIR` | A WoW Forever install (folder with `.build.info`) |
98
-
| `FOREVER_DB_TEST_DEFS` | A definitions snapshot (`defs.json.gz`), e.g. `internal/defs/data/forever.json.gz` |
107
+
| `FOREVER_DB_TEST_DEFS` | A definitions snapshot (`defs.json.gz`), e.g. `pkg/defs/data/forever.json.gz` |
99
| `FOREVER_DB_TEST_DBD_DIR` | A WoWDBDefs `definitions/` folder |
108
| `FOREVER_DB_TEST_DBD_DIR` | A WoWDBDefs `definitions/` folder |
100
| `FOREVER_DB_TEST_MANIFEST` | A WoWDBDefs `manifest.json` |
109
| `FOREVER_DB_TEST_MANIFEST` | A WoWDBDefs `manifest.json` |
101
| `FOREVER_DB_TEST_TACTKEYS` | A TACTKeys `WoW.txt` file |
110
| `FOREVER_DB_TEST_TACTKEYS` | A TACTKeys `WoW.txt` file |
@@ -107,7 +116,7 @@ WHERE ie."TriggerType" = 6 AND ie."SpellID" = ?;
The definitions snapshot (embedded, or written by `defs update`) is derived from these projects and is licensed under CC BY-SA 4.0; see `internal/defs/data/README.md`. The CASC, BLTE and WDC5 readers follow DBCD and TACTSharp (MIT); see `NOTICE`.
119
+
The definitions snapshot (embedded, or written by `defs update`) is derived from these projects and is licensed under CC BY-SA 4.0; see `pkg/defs/data/README.md`. The CASC, BLTE and WDC5 readers follow DBCD and TACTSharp (MIT); see `NOTICE`.
111
120
112
Copyright (C) 2026 bnema. SPDX-License-Identifier: AGPL-3.0-or-later. The project code is licensed under the GNU Affero General Public License v3.0 or later (see `LICENSE`).
121
Copyright (C) 2026 bnema. SPDX-License-Identifier: AGPL-3.0-or-later. The project code is licensed under the GNU Affero General Public License v3.0 or later (see `LICENSE`).
113
122
Acdn.test+0-0binary file: no text diff
binary file: no text diff
Mcmd/debug.go+4-4
@@ -8,10 +8,10 @@ import (
8
8
9
9
"github.com/spf13/cobra"
10
10
11
-
"github.com/bnema/forever-db/internal/casc"
12
-
"github.com/bnema/forever-db/internal/defs"
13
-
"github.com/bnema/forever-db/internal/install"
14
-
"github.com/bnema/forever-db/internal/tactkeys"
11
+
"bnema.dev/forever-db/pkg/casc"
12
+
"bnema.dev/forever-db/pkg/defs"
13
+
"bnema.dev/forever-db/pkg/install"
14
+
"bnema.dev/forever-db/pkg/tactkeys"
15
15
)
16
16
17
17
var debugCmd = &cobra.Command{
@@ -8,10 +8,10 @@ import (
8
8
9
"github.com/spf13/cobra"
9
"github.com/spf13/cobra"
10
10
11
-
"github.com/bnema/forever-db/internal/casc"
11
+
"bnema.dev/forever-db/pkg/casc"
12
-
"github.com/bnema/forever-db/internal/defs"
12
+
"bnema.dev/forever-db/pkg/defs"
13
-
"github.com/bnema/forever-db/internal/install"
13
+
"bnema.dev/forever-db/pkg/install"
14
-
"github.com/bnema/forever-db/internal/tactkeys"
14
+
"bnema.dev/forever-db/pkg/tactkeys"
15
)
15
)
16
16
17
var debugCmd = &cobra.Command{
17
var debugCmd = &cobra.Command{
Mcmd/defs.go+15-6
@@ -17,11 +17,13 @@ import (
17
17
18
18
"github.com/spf13/cobra"
19
19
20
-
"github.com/bnema/forever-db/internal/defs"
21
-
"github.com/bnema/forever-db/internal/fsutil"
22
-
"github.com/bnema/forever-db/internal/install"
23
-
"github.com/bnema/forever-db/internal/sources"
24
-
"github.com/bnema/forever-db/internal/tactkeys"
20
+
"bnema.dev/forever-db/internal/fsutil"
21
+
"bnema.dev/forever-db/pkg/casc"
22
+
"bnema.dev/forever-db/pkg/db2"
23
+
"bnema.dev/forever-db/pkg/defs"
24
+
"bnema.dev/forever-db/pkg/install"
25
+
"bnema.dev/forever-db/pkg/sources"
26
+
"bnema.dev/forever-db/pkg/tactkeys"
25
27
)
26
28
27
29
// Test hooks for defs update.
@@ -83,7 +85,14 @@ var defsUpdateCmd = &cobra.Command{
if g := flat(query(t, db, `SELECT error FROM _tables WHERE table_name='NoDef'`)); g != "layout 00000003 not in definitions snapshot (run forever-db defs update)" {
339
+
if g := flat(query(t, db, `SELECT error FROM _tables WHERE table_name='NoDef'`)); g != "layout 00000003 not in the definitions snapshot" {
if g := flat(query(t, db, `SELECT key,value FROM _meta WHERE key IN ('source','build_key','dbcache_status') ORDER BY 1`)); g != "build_key,bc;dbcache_status,missing;source,cdn" {
430
+
t.Errorf("_meta = %s", g)
431
+
}
432
+
db.Close()
433
+
// current.sqlite still points at the local export, which stays up to date.
if g := flat(query(t, db, `SELECT error FROM _tables WHERE table_name='NoDef'`)); g != "layout 00000003 not in definitions snapshot (run forever-db defs update)" {
339
+
if g := flat(query(t, db, `SELECT error FROM _tables WHERE table_name='NoDef'`)); g != "layout 00000003 not in the definitions snapshot" {
if g := flat(query(t, db, `SELECT key,value FROM _meta WHERE key IN ('source','build_key','dbcache_status') ORDER BY 1`)); g != "build_key,bc;dbcache_status,missing;source,cdn" {
430
+
t.Errorf("_meta = %s", g)
431
+
}
432
+
db.Close()
433
+
// current.sqlite still points at the local export, which stays up to date.