mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6995] [MERGED] fix(server): honor keepHostSettings for SQLite imports into PostgreSQL #6568
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#6568
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6995
Author: @HamedSanaei
Created: 10/28/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @MHSanaei
Base:
main← Head:codex/issue-6993-keep-host-settings📝 Commits (1)
061fa1ffix(server): preserve host settings on SQLite imports into PostgreSQL📊 Changes
3 files changed (+296 additions, -3 deletions)
View changed files
📝
.github/workflows/ci.yml(+9 -0)➕
internal/web/service/import_sqlite_postgres_test.go(+276 -0)📝
internal/web/service/server.go(+11 -3)📄 Description
Summary
SQLite
.dbbackups and SQLite SQL.dumpimports into a PostgreSQL panel now honor Keep this machine's settings. With the option enabled, the destination retains its panel/subscription listen addresses, ports, paths, certificates and node identity; ordinary settings, users, inbounds and clients still come from the upload. Disabling it remains the intentional full-clone mode.Fixes #6993. Related: #6227 and #5004.
Root cause and fix
importPostgresDBforwardedkeepHostSettingsonly for native PostgreSQL dumps. Both SQLite branches discarded it, andMigrateDatareplaced the entire settings table.Forward the flag for both SQLite formats. Reuse the existing host-bound snapshot/restore helpers: capture before closing the destination database, then restore only after migration succeeds and the database reopens. This retains the existing distinction between absent rows, explicitly empty values, and absent lazily generated mTLS material. A failed copy retains the existing transactional rollback/reopen behavior and does not reapply the snapshot over the rolled-back database.
The production change is limited to this SQLite-to-PostgreSQL service path. Native PostgreSQL dump restore, SQLite-panel imports, the CLI migration command, frontend/API contracts, and database schema are unchanged. Existing helper error-handling semantics are reused.
Regression coverage
The new integration test calls the public
ServerService.ImportDBwith actual SQLite files/SQL dumps and a real PostgreSQL destination. Each case uses a private schema and removes it afterward; the Xray executable is a harmless temporary process fixture, so no real panel/core installation is required.16 scenarios cover both formats with keep enabled/disabled and:
Successful cases also verify that source users, clients, inbounds and an ordinary setting are imported, replacing the destination data. The existing
postgres-migrationCI job now explicitly runs this suite and checks for its top-level PASS line, so a skipped/deleted test cannot silently satisfy the gate.Validation
Executed locally with Go 1.27.3 and a dedicated PostgreSQL 16 container:
go test ./internal/web/service -run '^TestImportSQLiteIntoPostgresHostSettings$' -count=1 -v— 16 scenarios passed against real PostgreSQL.-race— 16 scenarios passed, no race reports.go test ./internal/web/service ./internal/database -shuffle=on -count=1— passed with the ordinary SQLite test environment; PostgreSQL-only cases are exercised separately above.go vet ./internal/web/service ./internal/database— passed.golangci-lint run ./internal/web/service/...— passed, 0 issues.go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 -color -shellcheck=— passed.gofmt,git diff --check, andgit diff --cached --check— passed.No production database or running panel was used, and no live UI/HTTP restore or native
pg_restoreoperation was performed. No deployment or merge is included.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #6995] fix(server): honor keepHostSettings for SQLite imports into PostgreSQLto [PR #6995] [MERGED] fix(server): honor keepHostSettings for SQLite imports into PostgreSQL