#GeoDjango Project Deployed to Heroku - issues migrating tables.

1 messages · Page 1 of 1 (latest)

short stag
#

Hello,

I am new to Django (and web development in general), and this is my first time deploying a Django web app and commenting in the channel. I'm hitting some significant roadblocks (I've made a big mess) that I have been unable to resolve with my google searches or reading of the documentation. If anything, I have dug myself a deeper hole and would be most grateful for any suggestions or guidance anyone would be willing to offer.

Project:
a GeoDjango app deployed to Heroku, using PostgreSQL database, with a Postgis extension (the project uses GEOS, GDAL and PROJ4 libraries) as well as the leaflet.js library.

Issue:
my project is deployed on Heroku, and I'm starting with a fresh database for production. None of my tables have been migrated to PostgreSQL db on Heroku, and I am trying to migrate the tables. My local DB has now been cleared. I do have the following in my Procfile, so I thought the migrations would happen automatically.

web: gunicorn --pythonpath peaks peaks.wsgi ```

When my app updates to Heroku, the build initially succeeds and then fails with this message: 
  File "/app/.heroku/python/lib/python3.11/site-packages/django/db/migrations/loader.py", line 194, in check_key
    raise ValueError(
ValueError: Dependency on app with no migrations: beaks"
#

Part 2:
Note on project structure:
I messed up the build initially and have my app inside of another folder.
peaks-and-beaks (project name) > peaks (same level as .env, requirements.txt and README.md) > beaks folder (app containing static, templates, models, and views), media folder, peaks folder (containing urls, wsgi), and finally manage.py file). Running migrations as such, I will typically need to do: python peaks/manage.py migrate

What I have tried so far:
Initially, I was getting some error messages about the beaks.User, and saw some suggestions on stackoverflow to delete the migrations file and pycache files and run migrations again. I have done this as well as deleting the sqlite3 db (I had to use Postgres in development to be able to use the Postgis extension). To try and resolve the zero migrations, I have tried to migrate the files manually, but I run into the following error: "Migration beaks.0001_initial is applied before its dependency auth.0012_alter_user_first_name_max_length on database 'default'".

I have tried to migrate the AUTH file manually, commented out the AUTH file in seetings.py and then run the migrations. I have tried to comment out all mentions of the database. I have also tried to roll the migrations back to zero. However, none of these have yielded any success. My goal is to connect the tables to be able to start adding production data. I'm certain I've done something silly, but I am unsure where to go. Does anyone have any suggestions? If you've gotten this far, thank you for your time and for reading this.

verbal lantern
#

When you run migrate locally what happens?

short stag
# verbal lantern When you run migrate locally what happens?

Thank you very much for sharing that guide, it was really well-written and really helpful! It helped me identify some issues, and the mess I had made dropping some of my migration files, and not quite understanding what was happening when I was doing that. I, fortunately, didn't need any of my development data and landed up dropping my Postgres database and creating a new one on Heroku and it solved the problem. Thank you! Bookmarked it for the next inevitable mess I make 😄