I am wondering if it would be a good idea for a django app to name its migration directory and if nothing is provided then the name would default to 'migrations'.
The case: (let's call it a GEO app)
GEO app looks at the setting.py file for a flag called "GEO_USING_GEO_DJANGO".
# in models.py
if settings.GEO_USING_GEO_DJANGO:
from django.contrib.gis.db import models
from django.contrib.gis.geos import Point
else:
from django.db import models
class Location(models.Model):
if settings.GEO_USING_GEO_DJANGO:
point = models.PointField(_('Point'), default='POINT(0.0 0.0)')
else:
# lat/lng of location
lat = models.FloatField(_('Latitude'), default=0.0)
lng = models.FloatField(_('Longitude'), default=0.0)
objects = models.GeoManager() if settings.GEO_USING_GEO_DJANGO else models.Manager()
The above may not be the best practice here, but it works really well for people who don't want to install PostGIS and all the required software. All they have to do is to set GEO_USING_GEO_DJANGO = False and use geopy for lat/lng calculation.
This is to support both geoDjango and non-geoDjango users, and from the same source code.
Now, all works great till the first migration. Then game is over and the maintainer has to either stick with the geoDjango or the non-geoDjango version as far as the migration goes.
Only if the app could set its own migration directory!
in settings.py
---------------------
If GEO_USING_GEO_DJANGO:
GEO_MIGRATION_DIR_NAME = 'migrations_geo'
The maintainer of the app would set GEO_USING_GEO_DJANGO=True and run schemamigration, then set GEO_USING_GEO_DJANGO=False and rerun the schemamigration again. We'd end up with two distinct migration directories.
The end users just have to set GEO_USING_GEO_DJANGO=True/False.
I know this is not an ideal solution, but if avoiding duplicate versions of the same application was the final goal, this would achieve it.
This would complicate things for sure, but is there an easier way to avoid the duplicate source code?
Thanks,
Val