GeoNode / geonode

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

Django migrations table build in geonode_data? #12424

Open t-book opened 1 month ago

t-book commented 1 month ago

Expected Behavior

The django_migrations table should live in database geonode?

Should this not read --database=default instead of --database=datastore?

https://github.com/GeoNode/geonode/blob/4b6d872682ef0efd1ae61bf515b1f7d2250ba448/tasks.py#L326

or is there some reason to keep migrations table in geonode_data?

Actual Behavior

The table is created in geonode_data.

Steps to Reproduce the Problem

  1. start a stack from master

root@47ce2c613e4a:/usr/src/geonode# ./manage.py shell --settings=geonode.settings

In [1]: from django.conf import settings

In [2]: settings.DATABASES

Out[2]: 
{'default': {'NAME': 'geonode',
  'USER': 'geonode',
  'PASSWORD': 'pass',
  'HOST': 'db',
  'PORT': 5432,
  'CONN_MAX_AGE': 0,
  'CONN_HEALTH_CHECKS': False,
  'ENGINE': 'django.contrib.gis.db.backends.postgis',
  'OPTIONS': {'connect_timeout': 5},
  'ATOMIC_REQUESTS': False,
  'AUTOCOMMIT': True,
  'TIME_ZONE': None,
  'TEST': {'CHARSET': None,
   'COLLATION': None,
   'MIGRATE': True,
   'MIRROR': None,
   'NAME': None}},
 'datastore': {'NAME': 'geonode_data',
  'USER': 'geonode_data',
  'PASSWORD': 'pass',
  'HOST': 'db',
  'PORT': 5432,
  'CONN_MAX_AGE': 0,
  'CONN_HEALTH_CHECKS': False,
  'ENGINE': 'django.contrib.gis.db.backends.postgis',
  'OPTIONS': {'connect_timeout': 5}}}

$ geonodeuser@v2202404222509265991:~/geonode$ docker compose exec db bash
$e2b97dad486e:/# psql -U postgres -d geonode_data

geonode_data=# \dt;
                     List of relations
 Schema |            Name            | Type  |    Owner     
--------+----------------------------+-------+--------------
 public | django_migrations          | table | geonode_data <-- in geonode_data ?
 public | dynamic_models_fieldschema | table | geonode_data
 public | dynamic_models_modelschema | table | geonode_data
 public | gf_adminrule               | table | geonode_data
 public | gf_gfuser                  | table | geonode_data
 public | gf_gsinstance              | table | geonode_data
 public | gf_gsuser                  | table | geonode_data
 public | gf_layer_attributes        | table | geonode_data
 public | gf_layer_details           | table | geonode_data
 public | gf_layer_styles            | table | geonode_data
 public | gf_rule                    | table | geonode_data
 public | gf_rule_limits             | table | geonode_data
 public | gf_user_usergroups         | table | geonode_data
 public | gf_usergroup               | table | geonode_data
 public | spatial_ref_sys            | table | postgres

Specifications

mattiagiupponi commented 1 month ago

HI @t-book The migration to geonode-data is carried out by the geonode-importer tool. This importer not only handles the import process, but also enables the creation of dynamic models for each imported dataset. With this feature, the imported dataset can be directly queried from geonode, allowing users to navigate through the dataset data via Django.

Currently, the dynamic model feature is disabled by default, but it can be activated by adding the environment variable IMPORTER_ENABLE_DYN_MODELS. The migration on geonode-data is necessary for the dynamic model app. The Django-migration table is available there.

We can consider making the migration on geonode-data optional if the IMPORTER_ENABLE_DYN_MODELS is enabled.