Skip to content

Migration fails on NetBox Branching due to duplicate Custom Field (serializer) #182

@aoforb

Description

@aoforb

Validity Version

3.3.2

NetBox Version

4.4.6

Python Version

3.10

Steps to Reproduce

Validity’s squashed initial migration (0010_squashed_initial) tries to create a Custom Field named serializer even though it already exists in the shared database.

Branching replays migrations per branch, but the database is global, so uniqueness constraints apply across all branches.

Expected Behaviour

Migration should be idempotent and skip creating Custom Fields that already exist.

Image
  1. Have an existing branch
  2. Install Validity
  3. Go to UI Branching, select branch click Migrate button

Traceback

Error Message
IntegrityError('duplicate key value violates unique constraint "extras_customfield_name_key"\nDETAIL: Key (name)=(serializer) already exists.')

Log Message
{
    "log": [
        "Migrating branch core-switch-refresh (branch_7a6mf5u3)",
        "Setting branch status to migrating",
        "Applying migration validity.0010_squashed_initial",
        "duplicate key value violates unique constraint \"extras_customfield_name_key\"\nDETAIL:  Key (name)=(serializer) already exists."
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions