Skip to content

Database Migration Failure

Description

I wanted to migrate our local database, which we used for testing and "soft"-production, to a dedicated PostgreSQL Server.

Environment to reproduce

local v25.7.; database

Steps to reproduce

  1. Create local SQL script how to "recreate" the database via:
pg_dump -h localhost -p 5432 -U <user> -F p -b -v -f labid_db.sql labid-local-dev

I automatically renamed the user in the resulting labid_db.sql file to the user of the server.

  1. Uploaded the script and run it via SQL on the Server to construct the database. (No error messages)

  2. Adapted the DJANGO .env file

from:

DJANGO_DATABASE_URL=postgres://XXX@localhost:5432/labid-local-dev

to:

DJANGO_DATABASE_URL=postgres://<USERNAME>:<PASSWORD>@server:5432/cidbn_labid
  1. Started the Server

It did some migrations, mostly with result ok, some where skipped. After noticing the missing parts, I stoped and explicitely called the migration routines and started again. No change.

I believe the missing things are the ones which are skipped.

Example:

Applying stocks.0025_auto_20221223_1043... ['equipment']
 Got content_types: <QuerySet [<ContentType: stocks | equipment>]>
 owned_by
 ['storageequipment']
 Got content_types: <QuerySet [<ContentType: stocks | storage equipment>]>
 owned_by
 OK
  Applying stocks.0026_auto_20230320_1034... OK
  Applying stocks.0027_custom_20230213_1745... OK
  Applying stocks.0028_custom_20230419_1154... OK
  Applying stocks.0029_custom_20230425_1440... ['storageequipment']
 Got content_types: <QuerySet [<ContentType: stocks | storage equipment>]>
 short_name
 Skipped
 Skipped
...
 Skipped

I am not sure if I interpret the log correctly, that some of the items are not owned by the user but by storageequipment for instance?

What's the expected result?

All previous items / user etc. are available.

What's the actual result?

No previous data available. Not all standard GUI items available. Only admin standard user works for logging in.

Additional details / screenshots

Screenshot_2025-07-28_at_11.20.32


Is this type of migration possible at all (via the SQL script)?
Should I change something additionally in the settings?
Can I run extra migration steps etc?

Thank you in advance!

Edited by FSchwarz