Skip to main content

Database-First Migrations

https://gqc.atlassian.net/browse/CHAMA-45

I ran the command and got a list of models out. I think this is a decent first step for building models from an existing database. However, we get far too many tables for what we need. I think our best bet for building models for projects such as these is something like the following:

  • Create an empty database.
  • Use DBeaver to import tables into the DB.
  • Use django inspectdb command to get all tables.
  • Remove all models/tables EXCEPT for those corresponding to our imported layers (shape files, geojson, etc.)
  • Manually edit these shape models to be usable models
  • Modify meta data (managed = True)
  • Tweak attribute names to conform to Python/Django conventions. LEAVE COLUMN AND TABLE NAMES ALONE
  • Do migrations… not sure from here on out…