Skip to content

Downgrade to 2.58.4 from 2.59 causes data base errors and failure on boot #14988

@ChrisAAAllard

Description

@ChrisAAAllard

Bug description
Downgrading the application code from 2.59.0 to 2.58.x against a database already migrated to 2.59 leaves the schema and code out of sync, with no guard or clear error. The 2.59 migration removes the Credential Manager (drops dojo_cred_user/dojo_cred_mapping and the dojo_system_settings.enable_credentials column), but 2.58 code still expects them.

This produces two failures:

  1. The initializer crashes during pghistory trigger configuration because 2.58 still registers Cred_User with pghistory:

Configuring pghistory triggers

File "/app/dojo/management/commands/complete_initialization.py", line 36, in handle
configure_pghistory_triggers()
File "/app/dojo/auditlog/services.py", line 467, in configure_pghistory_triggers
call_command("pgtrigger", "enable")

psycopg.errors.UndefinedTable: relation "dojo_cred_user" does not exist

django.db.utils.ProgrammingError: relation "dojo_cred_user" does not exist

  1. Even once the app starts, a runtime banner appears on multiple pages because the code queries a column the 2.59 schema removed:

"Warning: Unable to load system settings from database: column dojo_system_settings.enable_credentials does not exist LINE 1: ...ings"."risk_acceptance_notify_before_expiration", "dojo_syst... ^. Default values are being used. Please check your database configuration and run migrations if needed."

Steps to reproduce

  1. Run DefectDojo 2.59.0 so the database is migrated to 2.59 (Credential Manager removed).
  2. Move the code back to 2.58.x against the same database (e.g., a docker compose pull/checkout landing on the older tag), then rebuild.
  3. Run docker compose up -d and watch docker compose logs -f initializer.
  4. See the initializer exit 1 on the pghistory step; if the app is forced up, see the enable_credentials banner on pages that read system settings.

Expected behavior
A downgrade against a newer schema should be detected and blocked with a clear message identifying a code/database version mismatch. At minimum the initializer error and the system-settings banner should point to the version mismatch as the cause.

Deployment method (select with an X)

  • Docker Compose
  • Kubernetes
  • GoDojo

Environment information

  • Operating System: Ubuntu 24.04.04
  • Docker Compose
  • DefectDojo version: downgraded from 2.59.0 to 2.58.4 (database at 2.59)

Additional context
Root cause was a downgrade, not data corruption. Recreating dojo_cred_user let 2.58 start but left the enable_credentials banner; the actual fix was recreating the missing table from the Credential Manager schema. Filing because the failure modes give no indication that a version/schema mismatch is the cause.

Image Image Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions