GeoNode / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
https://geonode.org/
Other
1.44k stars 1.13k forks source link

Upgrading from DEPRECATED_4.x fails due to database migration #10522

Closed lleirborras closed 1 year ago

lleirborras commented 1 year ago

Expected Behavior

Upgrading from DEPRECATED_4.x to 4.0.x, 4.1.x or master should let the application to start

Actual Behavior

After upgrading the app refuses to start due to database migrations

List of databases
         Name         |  Owner   | Encoding | Collate |    Ctype    |   Access privileges
----------------------+----------+----------+---------+-------------+-----------------------
 geonode              | geonode  | UTF8     | C       | en_US.UTF-8 |
 geonode_data         | postgres | UTF8     | C       | en_US.UTF-8 |
 geonode_data_initial | geonode  | UTF8     | C       | en_US.UTF-8 |
 geonode_ifad         | postgres | UTF8     | C       | en_US.UTF-8 |
 postgres             | postgres | UTF8     | C       | en_US.UTF-8 |
 powa                 | postgres | UTF8     | C       | en_US.UTF-8 |
 template0            | postgres | UTF8     | C       | en_US.UTF-8 | =c/postgres          +
                      |          |          |         |             | postgres=CTc/postgres
 template1            | postgres | UTF8     | C       | en_US.UTF-8 | =c/postgres          +
                      |          |          |         |             | postgres=CTc/postgres
(8 rows)
GeoNode databases are up - executing command
waitfordbs tasks done
**************************migrations*******************************
Traceback (most recent call last):
  File "/usr/src/geonode/manage.py", line 29, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 95, in handle
    executor.loader.check_consistent_history(connection)
  File "/usr/local/lib/python3.10/site-packages/django/db/migrations/loader.py", line 306, in check_consistent_history
    raise InconsistentMigrationHistory(
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration upload.0033_auto_20210531_1252 is applied before its dependency upload.0033_auto_20210528_1556 on database 'default'.

Steps to Reproduce the Problem

  1. Install Geonode using docker on branch DEPRECATED_4.x
  2. Run the app
  3. Change the branch to 4.0.x, 4.1.x or master
  4. Run the app

At this point the docker for Django will start respawning over and over after throwing the message shown before

Specifications

afabiani commented 1 year ago

@lleirborras connect to the geonode DB and run the following SQL statements

https://github.com/GeoNode/geonode/issues/10179#issuecomment-1285863020

lleirborras commented 1 year ago

@afabiani it seems to be working, thanks a lot for the trick!