[GeoNode-devel] Some thoughts about GeoNode db synchronization
Alessio Fabiani
alessio.fabiani at geo-solutions.it
Mon Aug 1 06:19:40 PDT 2016
Dear devs,
with the update to DJango 1.8.7 GeoNode must rely on migrations in order to
update the model from an old version to a newest one.
Basically the "syncdb" is somehow outdated or deprecated (if you want).
Now, from a point of view this is positive, since the model should be
automatically updated by DJango through the migrations, from another one is
not since on GeoNode based on Django 1.6.x there wasn't any way to update
the model in case of change.
The potential problems when updating an already existing GeoNode 2.4 DJango
1.6 instance:
1)
The initial migrations start from a GeoNode model with the mosaics already
in there. That means that DJango assumes the old GeoNode is aware of (and
should have created already) the 4 columns on the Layer model related to
the mosaic:
- is_mosaic BOOLEAN
- has_time BOOLEAN
- has_elevation BOOLEAN
- time_regex character varying
- elevation_regex character varying
That means that if those columns do not exist on the DB they must be added
manually
e.g.:
====
psql -U geonode geonode
geonode=> ALTER TABLE layers_layer ADD COLUMN is_mosaic BOOLEAN NOT NULL
DEFAULT FALSE;
geonode=> ALTER TABLE layers_layer ADD COLUMN has_time BOOLEAN NOT NULL
DEFAULT FALSE;
geonode=> ALTER TABLE layers_layer ADD COLUMN has_elevation BOOLEAN NOT
NULL DEFAULT FALSE;
geonode=> ALTER TABLE layers_layer ADD COLUMN time_regex character
varying(50);
geonode=> ALTER TABLE layers_layer ADD COLUMN elevation_regex character
varying(50);
2)
The Topic Categories are an update to the base model, that means that when
updating we must be sure the 0002 migration has been executed.
3)
>From now on, everytime the GeoNode is updated we MUST be sure the
migrations are updated too.
4)
The old GeoNode does not know how to migrate "auth" and "content-types"
Long story short, we should updated the documentation with a set of "use
cases" when updating GeoNode from an old 2.4 Django 1.6 based one to a
newer 2.4+ DJango 1.8+ based one.
Most probably the following set of commands
python manage.py syncdb --all
python manage.py migrate --fake
python manage.py migrate base 0002
psql -U geonode geonode
geonode=> ALTER TABLE layers_layer ADD COLUMN is_mosaic BOOLEAN NOT NULL
DEFAULT FALSE;
geonode=> ALTER TABLE layers_layer ADD COLUMN has_time BOOLEAN NOT NULL
DEFAULT FALSE;
geonode=> ALTER TABLE layers_layer ADD COLUMN has_elevation BOOLEAN NOT
NULL DEFAULT FALSE;
geonode=> ALTER TABLE layers_layer ADD COLUMN time_regex character
varying(50);
geonode=> ALTER TABLE layers_layer ADD COLUMN elevation_regex character
varying(50);
should work in the most cases, but it would be quite useful to:
a)
Discuss here how we want to manage this thing (we just write a detailed
documentation with use case and commands to execute, we try to create some
ad-h.o.c management commands to automatize and fix the database, something
else...)
b)
Try to test as much as possible use cases and take note of the correct
sequence of commands to fix the DB and successfully complete the migration
process.
What do you think about that?
Best Regards,
Alessio Fabiani.
==
GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information.
==
Ing. Alessio Fabiani
@alfa7691
Founder/Technical Lead
GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 331 6233686
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
-------------------------------------------------------
*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*
Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.
The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.
---------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-devel/attachments/20160801/eea3107b/attachment-0001.html>
More information about the geonode-devel
mailing list