mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6592] [MERGED] fix(database): keep the legacy tag cleanup from colliding with an existing tag #6367
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#6367
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/6592
Author: @n0ctal
Created: 9/17/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @MHSanaei
Base:
main← Head:upstream-pg-migration-requirements-fix📝 Commits (2)
43870fcfix(database): avoid legacy inbound tag cleanup collisions11a4f2atest(database): assert the legacy tag cleanup keeps the migration green📊 Changes
2 files changed (+69 additions, -7 deletions)
View changed files
📝
internal/web/service/inbound_migration.go(+13 -3)📝
internal/web/service/inbound_migration_test.go(+56 -4)📄 Description
Summary
The legacy
0.0.0.0:tag cleanup inMigrationRequirementscan rewrite aninbound's tag onto one another inbound already holds.
inbounds.tagisunique, so the statement fails — and because the cleanup shares a transaction
with every other requirement, that failure rolls all of them back on every
boot.
Why
An install carrying both
inbound-0.0.0.0:30004andinbound-30004— thesecond created after the address was dropped from new tags — makes this
statement collapse the first onto the second.
model.Inbound.Tagisgorm:"unique", so the UPDATE returns a unique violation.MigrationRequirementsreturns on that error, which abandons the transactionholding the client-traffics backfill, the share-address normalisation and the
rest.
MigrateDBonly logs it, so the panel starts, the migrations silentlydo not apply, and the same thing happens on the next boot.
Rows whose cleaned tag is already taken are now left alone. They keep a
cosmetically legacy tag, which is what the previous state already was, and
every other requirement commits.
Scope
MigrationRequirements: both the SQLite and the PostgreSQL form of thecleanup skip rows whose cleaned tag another row already holds.
TestMigrationRequirements_SkipsLegacyZeroAddrTagCollisionseeds thecolliding pair and asserts the legacy row is untouched.
Validation
go build ./...andgo vet ./internal/web/service/are clean.go test ./internal/web/service/ -run TestMigrationRequirementspasses onSQLite and against a real PostgreSQL 16 — the Postgres form needs
UPDATE inbounds AS ifor the correlated subquery, so it is worth runningon both.
MigrationRequirements: UNIQUE constraint failed: inbounds.tag.The second commit strengthens that test. As first written it asserted only
that the colliding tag was left unchanged — which the unguarded cleanup also
produces, since the UPDATE fails and the row stays as it was. Both states are
identical from the outside; what differs is whether the migration completed.
The test now asserts the call itself succeeds, which is the difference that
matters.
Risk
Low. The change narrows one UPDATE. An install with no colliding tags is
unaffected, and a colliding one keeps the tag it already had.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.