mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5707] Migration from v2.6.7 to v3.4.2: is it safe to reuse existing x-ui.db? #3971
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3971
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cyb3ralbert on GitHub (Jul 1, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5707
Question
We are running 3x-ui v2.6.7 in Docker and want to upgrade to v3.4.2.
Our setup:
./db/:/etc/x-ui/Is it safe to simply change the image tag from
v2.6.7tov3.4.2and reuse the existingx-ui.db?Specifically:
Thank you.
@github-actions[bot] commented on GitHub (Jul 1, 2026):
Short answer: yes, you can point
v3.4.2at your existingx-ui.db— the schema migration is automatic. The part that will actually break is your custom Telegram bot's calls to the panel REST API, for two separate reasons detailed below.1. Database schema — auto-migrated, no manual step needed
database.InitDB(internal/database/db.go), which runs on every panel start (including a baredocker run/compose upwith no extra command —DockerEntrypoint.shjust execs/app/x-ui, andx-uiwith no subcommand calls the samerunWebServer()asx-ui run), does two things automatically:AutoMigrateover all current models (new tables:clients,client_inbounds,hosts,nodes,api_tokens,client_groups,outbound_subscriptions, etc.).history_of_seeders, so each runs exactly once. The relevant one for you isClientsTable: in v2.6.7 clients lived only inside each inbound'ssettingsJSON blob; v3 normalizes them into the newclients/client_inboundstables the first time it sees your DB, without touching the original JSON. Related seeders also backfill missingemail, fix stringifiedtgId, and clean up legacy flow values.You do not need to run
x-ui migrateormigrate-dbfor this — that only applies to the separate SQLite→PostgreSQL path or extra one-off data cleanup. Just back up./db/x-ui.dbbefore switching the tag (stop the container first, then copy the file — it's a single file, no-wal/-shmsidecars, since the DB opens withjournal_mode=DELETE).2. REST API — yes, breaking changes, specifically for client management and auth
Comparing
web/controller/api.go/inbound.goat tagv2.6.7against the currentinternal/web/controller/:/panel/api/inbounds/*(e.g.POST /panel/api/inbounds/addClient,POST /panel/api/inbounds/updateClient/:clientId,POST /panel/api/inbounds/:id/delClient/:clientId,GET /panel/api/inbounds/getClientTraffics/:email), keyed by inbound id + a clientid, with the wholeInboundobject (including the JSONsettingsstring) as the payload. In v3.4.2 these live under a new/panel/api/clients/*group (internal/web/controller/client.go):POST /add,POST /update/:email,POST /del/:email,GET /traffic/:email,POST /resetTraffic/:email,POST /onlines, etc. — keyed by clientemail(a client is now a normalized entity attachable to multiple inbounds), with a different JSON payload shape. Any bot code hard-coded to the old paths/payloads will get 404s or bind errors and needs to be rewritten against the new endpoints (current reference: the in-panel Swagger docs at/panel/api-docs, generated from source so it always matches the running build).checkLogin) — there was no API-token concept at all (noapiTokensetting existed in v2.6.7). v3 adds CSRF checks (internal/web/middleware/security.go,internal/web/session/csrf.go) to every unsafe method (POST/PUT/DELETE) authenticated via session cookie — includingPOST /loginitself. A cookie-based client must firstGET /panel/csrf-token(public, safe method) to obtain a token tied to its session, then send it back as theX-CSRF-Tokenheader (or_csrfform field) on/loginand every subsequent mutating call. If your bot currently just POSTs credentials to/loginand reuses the cookie for POSTs, as was sufficient in v2.6.7, it will start getting403 Forbidden.checkAPIAuthininternal/web/controller/api.gosetsapi_authed, which the CSRF middleware short-circuits on). Generate/view a token withdocker exec -it <container> /app/x-ui setting -getApiToken, or from the panel under Settings → API Tokens, then sendAuthorization: Bearer <token>on every request.3. Reality inbounds
I found no Reality-specific migration code (no rewrite of
streamSettings.realitySettingsanywhere ininternal/database/), and no matching reports in this repo's issue tracker of Reality inbounds breaking specifically from a v2→v3 database upgrade. The raw JSON is carried through unchanged, so your existing Reality config should generate the same Xray config after upgrade. That said, I can't rule out unrelated bugs — after upgrading, check /panel → Xray logs (ordocker logs) and confirm at least one client can still connect before considering the migration done.Recommended upgrade sequence
docker compose down(or stop the container), copy./db/x-ui.dbsomewhere safe.v3.4.2and start it back up — schema/data migration happens automatically on that first boot./panel/api/clients/*(not/panel/api/inbounds/...Client...) and switch it toAuthorization: Bearer <token>instead of session-cookie login.This reply was generated automatically and a maintainer may follow up.