Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown by 0074_drop_curated_thumbs when upgrading from 3.3.x to 4.x #15

Open
giohappy opened this issue Jun 20, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@giohappy
Copy link
Contributor

giohappy commented Jun 20, 2022

Migration 0074_drop_curated_thumbs threw the following exception while upgrading from 3.3.x demo to 4.x.

File "/usr/src/geonode_master/manage.py", line 31, 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 244, in handle
  post_migrate_state = executor.migrate(
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 117, in migrate
  state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
  state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
  state = migration.apply(state, schema_editor)
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/migration.py", line 126, in apply
  operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/usr/local/lib/python3.10/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
  self.code(from_state.apps, schema_editor)
File "/usr/local/lib/python3.10/site-packages/geonode/base/migrations/0074_drop_curated_thumbs.py", line 26, in update_thumbnail_urls_and_delete_curated_thumbs_folder
  filename = _generate_thumbnail_name(resource.get_real_instance())
File "/usr/local/lib/python3.10/site-packages/polymorphic/models.py", line 173, in get_real_instance
  return real_model.objects.db_manager(self._state.db).get(pk=self.pk)
django4geonode_demo | AttributeError: 'NoneType' object has no attribute 'objects'

Testing the retrieval of the "real instance" models manually (shell script)) we get the following:

Real instance 'test map by admin' found for resource_id:78 - map
Real instance 'Adagio - Johann Sebastian Bach.mp3' found for resource_id:70 - document
No real instance found for resource_id:225 - geostory
Real instance 'remote file' found for resource_id:222 - document
Real instance 'new by admin' found for resource_id:228 - map
No real instance found for resource_id:221 - layer
No real instance found for resource_id:334 - layer
Real instance 'racconto.pdf' found for resource_id:338 - document

It looks like it fails retrieving the polymorphic types for geostory and layers.

@giohappy giohappy added the bug Something isn't working label Jun 20, 2022
@marthamareal
Copy link

@giohappy this happens because the resources polymorphic_ctype models are not changed yet. eg layer to dataset.

For a moment the issue is solved by running migrations for apps layers, geoapps, geonode_mapstore_client before running the above migration.

Also, there are some migrations from 4.x which are already applied in 3.3.x. these are skipped with --fake flag.
These migrations include:

base.0080_alter_resourcebase_uuid
upload.0034_uploadsizelimit
upload.0035_update_uploadsizelimit_objects
upload.0036_upload_store_spatial_files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants